我正在使用AngularJS和ASP.NET Identity 2处理单页应用程序.我将用户登录并设置了cookie; 但是,当我在同一请求中检查用户的身份时,它会将其显示为空白,并且IsAuthenticated为false.但是,这些都会在后续请求中填充.我希望无论用户是否在同一请求中登录,都会向UI发回.这可能吗?
代码按要求(AngularJS使AJAX发布到WebAPI控制器登录方法)
[HttpPost]
[AllowAnonymous]
[Route("Login")]
public async Task<IHttpActionResult> Login(LoginModel loginModel)
{
var result = await _securityService.Login(loginModel.UserName, loginModel.Password);
if (!result)
{
ModelState.AddModelError("errorMessage", "Invalid username or password.");
return BadRequest(ModelState);
}
return Ok();
}
public async Task<bool> Login(string userName, string password, bool persistCookie = false)
{
var user = await _userManager.FindAsync(userName, password);
if (user != null)
await SignInAsync(user, persistCookie);
else
return false;
return true;
}
private async Task SignInAsync(ApplicationUser user, bool isPersistent)
{
_authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
_authenticationManager.SignIn(new AuthenticationProperties() {IsPersistent = isPersistent}, await …Run Code Online (Sandbox Code Playgroud) 我目前在Azure上托管我的redis缓存服务器,并使用以下信号依赖signalR作为主干...
GlobalHost.DependencyResolver.UseRedis( "服务器",港口, "密码", "eventKey");
这可以在端口6379(非SSL)上找到,但是当我尝试连接到Azure Redis服务器的SSL端口(6380)时,我的聊天应用程序中断了,并且集线器从未启动过.这个问题可能是什么原因?或者我做错了什么?
这是我的浏览器net :: ERR_CONNECTION_RESET中/ signalr/connect上出现的错误
redis signalr signalr-hub signalr-backplane azure-redis-cache