Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 如何判断ASP.NET模拟是否正常工作?_Asp.net Mvc 3_Iis 7.5_Impersonation - Fatal编程技术网

Asp.net mvc 3 如何判断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

使用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 according to our configuration => 
    // we can work with his username
    string username = User.Identity.Name;
    ...
}

等等,我很确定Identity.Name具有用户名,无论是否启用模拟。