简体   繁体   English

ASP.NET身份和SignalR

[英]ASP.NET Identity and SignalR

I'm trying to use ASP.NET Identity and SignalR (2.0.1) in new default project. 我正在尝试在新的默认项目中使用ASP.NET Identity和SignalR(2.0.1)。

When I comment line app.MapSignalR(); 当我评论行app.MapSignalR(); in class Startup, login is working perfect. 在Startup类中,登录工作正常。 I get "user" in method LogIn, username of logged user is show on page (via Context.User.Identity.GetUserName() ). 我在方法LogIn中获得“user”,登录用户的用户名显示在页面上(通过Context.User.Identity.GetUserName() )。

When I uncomment line app.MapSignalR(); 当我取消注释行app.MapSignalR(); in class Startup, I get "user" in method LogIn but username of logged user is not show. 在Startup类中,我在方法LogIn中得到“user”,但是没有显示已登录用户的用户名。 When I was using old memebership and SignalR, everything worked ok. 当我使用旧的memebership和SignalR时,一切正常。 Did I miss something? 我错过了什么?

protected void LogIn(object sender, EventArgs e)
{
    if (IsValid)
    {
        // Validate the user password
        var manager = new UserManager();
        ApplicationUser user = manager.Find(UserName.Text, Password.Text);
        if (user != null)
        {
            IdentityHelper.SignIn(manager, user, RememberMe.Checked);
            IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
        }
        else
        {
            FailureText.Text = "Invalid username or password.";
            ErrorMessage.Visible = true;
        }
    }
}


using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof(Tmp.Startup))]
namespace Tmp
{
    public partial class Startup {
        public void Configuration(IAppBuilder app) {
            app.MapSignalR();
        }
    }
}

Check your packages looks like your using webforms and SignalR. 检查您的包看起来像使用webforms和SignalR。 SignalR runs on the owin pipeline. SignalR在owin管道上运行。

If your running IIS you're need the following packages: 如果您正在运行IIS,则需要以下软件包:

  • Microsoft.Owin.Host.SystemWeb (OWIN-based applications to run on IIS using the ASP.NET request pipeline in your case webforms) Microsoft.Owin.Host.SystemWeb(在您的案例webforms中使用ASP.NET请求管道在IIS上运行的基于OWIN的应用程序)

  • Microsoft.AspNet.SignalR.SystemWeb (Allows SignalR to run on IIS using the ASP.NET request pipeline) Microsoft.AspNet.SignalR.SystemWeb(允许SignalR使用ASP.NET请求管道在IIS上运行)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM