? ?
if (Membership.ValidateUser(_model.UserName, _model.Password))
{
FormsAuthentication.SetAuthCookie(_model.UserName, true);
// set redirect
}
, web.config:
<authentication mode="Forms">
<forms timeout="15" />
</authentication>
, cookie, . User.Identity.Name. MVC Controller, ApiController s.
, MVC WebAPI - ( ), MVC WebAPI machineKey web.config . , web.config, machineKey (decryption, decryptionKey, validation validationKey). , , cookie.ASPXAUTH.
cookie WebAPI?
, cookie, , /. HTTP, , , .. WebAPI - . , . , .
, , :
HttpCookie authCookie = HttpContext.Current.Request.Cookies["name"];
cookie ApiController, :
IEnumerable<CookieHeaderValue> cookies = this.Request.Headers.GetCookies("name");
if (cookies.Any())
{
IEnumerable<CookieState> cookie = cookies.First().Cookie;
if (cookie.Any())
{
string value = cookie.First().Value;
}
}
: http://aspnetresources.com/tools/machineKey
" ", <machineKey ../> - <system.web> web.config.
, web.config, . , , , , .
, , , . validationKey encryptionKey appSettings, appSettings ( - CloudConfigCrypto). , -, . Microsoft.Web.Administration.ServerManager machineKey , Application_Start. , , .
- , web.config .