IIS Express gives Access Denied error when debuggi

2019-01-12 18:20发布

I have created an ASP.NET MVC 3 project, and am using IIS Express as the web server when developing. When I try to debug, I get the error message below.

How can this be solved?

Server Error in '/' Application.

Access is denied. Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.

14条回答
祖国的老花朵
2楼-- · 2019-01-12 18:44

I had to run Visual Studio in Administrative Mode to get rid of this error.

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-01-12 18:47

The cause if had for this problem was IIS Express not allowing WindowsAuthentication. This can be enabled by setting

<windowsAuthentication enabled="true">

in the applicationhost.config file located at C:\Users[username]\Documents\IISExpress\config.

查看更多
smile是对你的礼貌
4楼-- · 2019-01-12 18:52

I opened my web.config file, and found and removed this section:

<authorization>
  <deny users="?" />
</authorization>

and my site came up, but there are issuues with the authentication..

查看更多
姐就是有狂的资本
5楼-- · 2019-01-12 18:53

None of the above had worked for me. This had been working for me prior to today. I then realized I had been working with creating a hosted connection on my laptop and had Shared an internet connection with my Wireless Network Connection.

To fix my issue:

Go to Control Panel > Network and Internet > Network Connections

Right click on any secondary Wireless Network Connection you may have (mine was named Wireless Network Connection 2) and click 'Properties'.

Go to the 'Sharing' tab at the top.

Uncheck the box that states 'Allow other network users to connect through this computer's Internet connection'.

Hit OK > then Apply.

Hope this helps!

查看更多
仙女界的扛把子
6楼-- · 2019-01-12 18:53

I didn't see this "complete" answer anywhere; I just saw the one about changing port numbers after I posted this, so meh.

Make sure that in your project properties in visual studio that project url is not assigned to the same url or port that is being used in IIS for any site bindings.

I'm looking up the "why" for this, but my assumption off the top of my head is that both IIS and Visual Studio's IIS express use the same directory when creating virtual directories and Visual Studio can only create new virtual directories and cannot modify any that IIS has created when it applies it's bindings to the site.

feel free to correct me on the why.

查看更多
来,给爷笑一个
7楼-- · 2019-01-12 18:55

I had also the same problem and finally I could overcame it.

Solution ExplorerRight click on projectPropertiesWeb tabProject Url

I have chosen another port number, and every things became fine!

查看更多
登录 后发表回答