当前位置: 动力学知识库 > 问答 > 编程问答 >

Visual Studio 2010 and Cassini web server can't make windows authentication! (Access Denied 401.2)

问题描述:

How it could be difficult to make a web site which is integrated with domain authentication in visual studio!?

This is my web.config:

 <authentication mode="Windows"/>

<identity impersonate="true"/>

<authorization>

<allow users="xxxDomains\yyyGroup"/>

<deny users="*"/>

</authorization>

This is the result:

But I think there would be a logon dialog which is for entering domain_name\username and password. Bu page is directed me always to the Access Denied Page without asking my username and password.

PS: I'm not belong to any domain. I want to use visual studio's web server(cassini). I will deploy the site after finishing project, I don't want to deploy project to web server in every F5 ...

Any help would be appreciated...

网友答案:

I guess what you are missing is checking the box for NTML Authentification in your web projects properties under Servers in the Web tab.

Anyhow, I would recommend upgrading to IIS Express 7.5, which is a simple and self-contained version of IIS that is optimized for developers:

  • The way IIS Express treats Windows Authentication is the same as a "real" IIS instance.

  • You still have the comfort of a local development server (e.g. F5) without deploying.

  • The ASP.NET Development Server is not developed anymore by Microsoft and will be replaced by IIS Express in future releases of Visual Studio.

See also this blog post by Scott Guthrie for more information on IIS Express or this article.

Hope this helps!

网友答案:

In solution explorer pane select the Web Project and hit F4. (not right click+properties, thats different)

In properties Pane set: Windows Authentication: Enable Anonymous Authentication: Disabled

In Web.config: <authentication mode="Windows"></authentication>

To get Username:

HttpContext.Current.User.Identity.Name OR User.Identity.Name

Run your project, Happy Days!

分享给朋友:
您可能感兴趣的文章:
随机阅读: