最近做登录验证的时候出现了一个问题,login的返回值为ActionResult,代码如下:
public async Task<ActionResult> Login(string returnUrl = "")
{
ClaimsIdentity userClaims = null;
var needAdLogin = true;
//域登陆
if (needAdLogin)
{
var name = this.HttpContext.User.Identity.Name;
var startOfSlash = name.IndexOf("\\", StringComparison.Ordinal);
var userName = name.Substring(startOfSlash + 1, name.Length - startOfSlash - 1);
var user = _userRepository.FirstOrDefault(r => r.UserName.Equals(userName));
if (user != null)
{
//do something here...
}
else
{
return Json("账户名不存在数据库中&