相关疑难解决方法(0)

ASP.NET_SessionId + OWIN Cookies不会发送到浏览器

使用Owin cookie身份验证时遇到一个奇怪的问题.

当我启动我的IIS服务器时,身份验证在IE/Firefox和Chrome上运行得非常好.

我开始使用身份验证进行一些测试并在不同的平台上登录,我想出了一个奇怪的错误.偶尔Owin框架/ IIS只是不向浏览器发送任何cookie.我将输入一个用户名和密码,该代码运行正确,但根本没有cookie传递给浏览器.如果我重新启动服务器它开始工作,那么在某些时候我将尝试登录并再次cookie停止交付.单步执行代码不会做任何事情并且不会抛出任何错误.

 app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationMode = AuthenticationMode.Active,
            CookieHttpOnly = true,
            AuthenticationType = "ABC",
            LoginPath = new PathString("/Account/Login"),
            CookiePath = "/",
            CookieName = "ABC",
            Provider = new CookieAuthenticationProvider
               {
                  OnApplyRedirect = ctx =>
                  {
                     if (!IsAjaxRequest(ctx.Request))
                     {
                        ctx.Response.Redirect(ctx.RedirectUri);
                     }
                 }
               }
        });
Run Code Online (Sandbox Code Playgroud)

在我的登录程序中,我有以下代码:

IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
                            authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);

var authentication = HttpContext.Current.GetOwinContext().Authentication;
var identity = new ClaimsIdentity("ABC");
identity.AddClaim(new Claim(ClaimTypes.Name, user.Username));
identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.User_ID.ToString()));
identity.AddClaim(new Claim(ClaimTypes.Role, role.myRole.ToString()));
    authentication.AuthenticationResponseGrant =
        new AuthenticationResponseGrant(identity, new AuthenticationProperties()
                                                   {
                                                       IsPersistent = isPersistent
                                                   }); …
Run Code Online (Sandbox Code Playgroud)

asp.net owin katana asp.net-identity

136
推荐指数
5
解决办法
6万
查看次数

在本地主机上运行的 asp.net 应用程序上使用 https

我创建了一个 asp.net Web 应用程序,其中包含一个名为“Main.aspx”的 Web 表单。我正在尝试通过 https 运行该应用程序。由于我没有 SSL、IIS 等方面的经验。我在 google 上搜索了如何实现这一目标,但每个解决方案都不适合我。

我使用以下步骤启用了 SSL:启用 SSL

我的应用程序现在正在https://localhost:59917/上运行。

在此输入图像描述

但如果我启动我的应用程序,我会收到一条 Firefox 错误消息:“安全连接失败”。所以我按照Scott Gu 的博客文章中的步骤进行操作,但也不起作用。

有谁有 SSL 和 ASP.net Web 应用程序的经验并且可以帮助我吗?

asp.net iis ssl https

5
推荐指数
1
解决办法
5294
查看次数

标签 统计

asp.net ×2

asp.net-identity ×1

https ×1

iis ×1

katana ×1

owin ×1

ssl ×1