using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; using System.Web; using System.Web.Http; using Resources.Helper; namespace Weee.Controllers { public class SetCultureController : ApiController { // POST api/ [AllowAnonymous] [Route("api/SetCulture/{culture}")] [HttpPost] public void Post(string culture) { culture = CultureHelper.GetImplementedCulture(culture); // Save culture in a cookie HttpCookie cookie = HttpContext.Current.Request.Cookies["_culture"]; // 改多國語系的地方 if (cookie != null) cookie.Value = culture; // update cookie value else { cookie = new HttpCookie("_culture"); cookie.Value = culture; cookie.Expires = DateTime.Now.AddYears(1); } HttpContext.Current.Response.Cookies.Add(cookie); } } }