Asp.net mvc IE和旧浏览器中的跨域会话asp mvc
假设您有网站和许多子域,例如: 假设用户访问last.simple.com,并通过普通的ASP.NET成员资格提供程序进行身份验证 然后,从该站点,它们被发送到重定向、链接、任何工作站点,该站点的意图是将该用户作为已验证的状态传递到另一个站点,以便该站点不再要求该用户的凭据 这在Chrome、Mozila、Operalast版本、Safari中有效,但在IEall版本和OperaAsp.net mvc IE和旧浏览器中的跨域会话asp mvc,asp.net-mvc,json,session,cross-domain,session-cookies,Asp.net Mvc,Json,Session,Cross Domain,Session Cookies,假设您有网站和许多子域,例如: 假设用户访问last.simple.com,并通过普通的ASP.NET成员资格提供程序进行身份验证 然后,从该站点,它们被发送到重定向、链接、任何工作站点,该站点的意图是将该用户作为已验证的状态传递到另一个站点,以便该站点不再要求该用户的凭据 这在Chrome、Mozila、Operalast版本、Safari中有效,但在IEall版本和Opera向服务器发送查询,json应答, 如果验证-重定向。Jsonned使用“jsonp”可能有问题吗 web.config
<system.web>
<authentication mode="Forms">
<forms name=".ASPXAUTH" protection="All" domain=".simple.com" enableCrossAppRedirects="true" />
</authentication>
</system.web>
public void Authenticate(string username)
{
FormsAuthentication.SetAuthCookie(username, false);
var cookie = FormsAuthentication.GetAuthCookie(username, false);
cookie.HttpOnly = true;
cookie.Path = "/";
cookie.Domain = domain;
this.context.Response.AppendCookie(cookie);
}
protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{
const string aspSessionid = "ASP.NET_SessionId";
if (Context.Handler is IRequiresSessionState || Context.Handler is IReadOnlySessionState)
{
var cookie = Context.Request.Cookies[aspSessionid];
if (cookie != null && Context.Session != null && !string.IsNullOrEmpty(Session.SessionID))
{
Response.Cookies.Add(new HttpCookie(aspSessionid, Session.SessionID) { Domain = domain, Path = "/", Expires = DateTime.Now.AddDays(30) });
}
}
}