Asp.net mvc 3 如何判断ASP.NET模拟是否正常工作?
使用ASP.NET模拟,可以使用Asp.net mvc 3 如何判断ASP.NET模拟是否正常工作?,asp.net-mvc-3,iis-7.5,impersonation,Asp.net Mvc 3,Iis 7.5,Impersonation,使用ASP.NET模拟,可以使用Environment.UserName确定模拟是否有效吗?也就是说,如果站点模拟正确,是否应该Environment.UserName返回我的用户名?您应该使用User.Identity.Name: [Authorize] public ActionResult Foo() { // If we got so far it means that the user is authorized to // execute this action a
Environment.UserName
确定模拟是否有效吗?也就是说,如果站点模拟正确,是否应该Environment.UserName
返回我的用户名?您应该使用User.Identity.Name
:
[Authorize]
public ActionResult Foo()
{
// If we got so far it means that the user is authorized to
// execute this action according to our configuration =>
// we can work with his username
string username = User.Identity.Name;
...
}
等等,我很确定Identity.Name具有用户名,无论是否启用模拟。