我正在使用mvc应用程序和带有asp.net身份的web api 2.我的客户端mvc应用程序使用令牌,它在登录提交按钮上给出api调用然后web api服务返回一个令牌和用户声明(即用户名)我的问题是以下:
-
如何在我的mvc应用程序中使用IsAuthenticated属性,因为它始终为false .
-
如何根据我的用途记住我的功能 .
-
我的api是否有必要返回userclaim-username和accessstoken以及其他数据,我可以按照用户的说法收到电子邮件和电话 .
Update:
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
if (!ModelState.IsValid)
{
return View(model);
}
var responseDictionary = GetResponseAsDictionary(model.usename, model.password);
return View(model);
}
我从web api获得这个响应字典
现在如何在服务中使用此令牌设置 IsAuthenticated
?我知道如何在表单身份验证中执行此操作,但我不知道如何使用AccessTokens执行此操作,并且我还希望在tempData或session中的用户会话中保留此标记 .
1 回答