Plugins.Add(new AuthFeature(
() => new AuthUserSession(),
new IAuthProvider[] { new BasicAuthProvider(new AppSettings()), }));
Plugins.Add(new RegistrationFeature());
container.Register<ICacheClient>(new MemoryCacheClient());
var userRepository = new InMemoryAuthRepository();
container.Register<IUserAuthRepository>(userRepository);
string hash;
string salt;
new SaltedHash().GetHashAndSaltString("password", out hash, out salt);
userRepository.CreateUserAuth(new UserAuth
{
Id = 1,
DisplayName = "JoeUser",
Email = "joe@user.com",
UserName = "hal",
FirstName = "Joe",
LastName = "User",
PasswordHash = hash,
Salt = salt,
Roles = new List<string> { RoleNames.Admin },
//Permissions = new List<string>{"GetStatus"}
}, "password");
这是全局 asax 文件,我使用此代码进行身份验证
[Route("/ClientList/", "POST")]
[ Authenticate]
public class ClientGet
{
public string username { get; set; }
public string password { get; set; }
}
在我尝试的单点触控阶段
client = new JsonServiceClient ("http://sampleurl.com/api/authenticate/Basic?format=json") {
UserName = "hal",
Password = "password"
};
或客户端 = new JsonServiceClient (" http://sampleurl.com/api ) {Username="Hal", Password="password");
它给了我请求超时问题
有更新吗?
谢谢