ASP.NET Core - 发布应用程序时无法使用signInManager进行签名

时间:2017-06-13 20:03:35

标签: c# asp.net-core asp.net-core-mvc asp.net-core-identity

我有一个在本地运行的ASP.NET核心应用程序,我可以毫无问题地登录。但是,当我将应用程序发布到服务器时,我无法登录。我收到以下错误:找不到此页面。我的服务器上是否需要配置一些能够登录我的应用程序的东西?

以下是我用来登录的服务:

public class IdentityAuthenticationService : IAuthenticationService
{
    private UserManager<IdentityApplicationUser> userManager;
    private SignInManager<IdentityApplicationUser> signInManager;
    private RoleManager<IdentityRole> roleManager;

    public IdentityAuthenticationService
    (
        UserManager<IdentityApplicationUser> userManager, 
        SignInManager<IdentityApplicationUser> signInManager,
        RoleManager<IdentityRole> roleManager
    )
    {
        this.userManager = userManager;
        this.signInManager = signInManager;
        this.roleManager = roleManager;
    }

    public async Task LoginAsync(string username, string password)
    {
        //This line is where the error comes from             
        var result = await signInManager.PasswordSignInAsync(username, password, isPersistent: false, lockoutOnFailure: false);
        if (!result.Succeeded) {
            throw new InvalidLoginException();
        }
    }
    [...]

1 个答案:

答案 0 :(得分:0)

你发表了这个项目吗? Refer this link

您是否设置了“启动默认”页面?在webconfig中? 像这样的东西

 <authentication mode="Forms">
  <forms loginUrl="login.aspx" protection="All" timeout="120" name=".ASPXAUTH" requireSSL="false" slidingExpiration="true" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false"/>
</authentication>