手动创建票证:
var ticket = new FormsAuthenticationTicket(
1,
username,
DateTime.Now,
DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes),
false,
"no,data",
FormsAuthentication.FormsCookiePath
);
var encryptedTicket = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
{
HttpOnly = FormsAuthentication.RequireSSL,
Path = FormsAuthentication.FormsCookiePath,
Domain = FormsAuthentication.CookieDomain
};
HttpContext.Current.Response.AppendCookie(cookie);
Web.Config文件:
<forms loginUrl="~/LogOn"
name="ticket"
timeout="1"
slidingExpiration="true"
path="/" />
故障单创建发生在ASP.NET Web API中的方法中,客户端是与REST API通信的iPhone。
谢谢!