Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc IE和旧浏览器中的跨域会话asp mvc_Asp.net Mvc_Json_Session_Cross Domain_Session Cookies - Fatal编程技术网

Asp.net mvc IE和旧浏览器中的跨域会话asp mvc

Asp.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

假设您有网站和许多子域,例如:

假设用户访问last.simple.com,并通过普通的ASP.NET成员资格提供程序进行身份验证

然后,从该站点,它们被发送到重定向、链接、任何工作站点,该站点的意图是将该用户作为已验证的状态传递到另一个站点,以便该站点不再要求该用户的凭据

这在Chrome、Mozila、Operalast版本、Safari中有效,但在IEall版本和Opera 方案:

用户,addressfirst.simple.com->向服务器发送查询,json应答, 如果验证-重定向。Jsonned使用“jsonp”可能有问题吗

web.config

Global.asax

<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) });
            }
        }
    }