servicestack,Asp.net Mvc,Authentication,servicestack" /> servicestack,Asp.net Mvc,Authentication,servicestack" />

Asp.net mvc ServiceStack CustomAuthenticationMvc管理员密码?

Asp.net mvc ServiceStack CustomAuthenticationMvc管理员密码?,asp.net-mvc,authentication,servicestack,Asp.net Mvc,Authentication,servicestack,我正在运行CustomAuthenticationMvc的ServiceStack用例示例,但当我尝试登录时,我会在asp mvc登录页面中进行搜索 用户:管理员 密码:123 但显示错误消息(无效用户名或密码),因此在CustomValidation项目中,但在ASP.NET中,这些是访问HelloService的de用户名和密码。。。那么,CustomAuthenticationMvc中访问HelloService的用户名和密码是什么 谢谢如果您查看AppHost.cs,您可以看到身份验证是

我正在运行CustomAuthenticationMvc的ServiceStack用例示例,但当我尝试登录时,我会在asp mvc登录页面中进行搜索

用户:管理员 密码:123

但显示错误消息(无效用户名或密码),因此在CustomValidation项目中,但在ASP.NET中,这些是访问HelloService的de用户名和密码。。。那么,CustomAuthenticationMvc中访问HelloService的用户名和密码是什么


谢谢

如果您查看AppHost.cs,您可以看到身份验证是如何执行的:

public class CustomCredentialsAuthProvider : CredentialsAuthProvider
{
    public override bool TryAuthenticate(IServiceBase authService, string userName, string password)
    {
        if (!Membership.ValidateUser(userName, password)) return false;
        ....
    }
}
因此,它使用成员资格提供者框架对用户进行身份验证

默认情况下,它将使用SimpleMembership(参见示例),默认连接来自web.config:

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-CustomAuthenticationMvc-20121011213234;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
</connectionStrings>
在某个地方用种子法。为了简单起见,您可以将它放在
AccountController
Login
方法中


或者,如果您不介意这些,您可以模仿CustomAuthentication项目中的代码

i、 e.更换

if (!Membership.ValidateUser(userName, password)) return false;

if (!Membership.ValidateUser(userName, password)) return false;
if (!CheckInDB(userName, password)) return false;

...

private bool CheckInDB(string userName, string password)
{
    if (userName != "admin" && userName != "user") return false;
    return password == "123";
}