部署到hostgator的ASP.NET MVC身份验证cookie无法正常工作

时间:2019-08-11 14:22:36

标签: asp.net-mvc authentication

我在我的站点中使用ASP.NET MVC 5身份验证cookie。在我的本地环境中,身份验证正常进行。

另外,当我将网站部署到Goddady共享主机托管时,一切正常。

但是,当我将完全相同的站点部署到hostgator共享主机时,登录后,尝试访问任何控制器操作后,用户将被重定向回登录页面。在请求中,我看到Asp.Authentication.Cookie作为请求标头的一部分发送,但是,我从服务器收到302响应,并且用户被重定向到登录页面(因为我认为授权失败)。

我不知道为什么会这样。

下面是我的startup.auth:

// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login")
        });

// Use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

以及登录时使用的登录方法:

AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);

var identity = await _userManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);

这是登录后发出的示例请求:

enter image description here

响应为302

更新

我想知道这是否是IIS版本问题,因为神日使用v8.5,hostgator使用v10。

无论哪种方式,我都移至bisend.com并不得不取消hostgator

0 个答案:

没有答案
相关问题