asp.net-mvc IIS Express 在调试 ASP.NET MVC 时出现拒绝访问错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9053666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IIS Express gives Access Denied error when debugging ASP.NET MVC
提问by Kris-I
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.
我创建了一个 ASP.NET MVC 3 项目,并且在开发时使用 IIS Express 作为 Web 服务器。当我尝试调试时,我收到以下错误消息。
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.
“/”应用程序中的服务器错误。
访问被拒绝。描述:访问服务此请求所需的资源时发生错误。服务器可能未配置为访问请求的 URL。
错误消息 401.2。:未经授权:由于服务器配置,登录失败。根据您提供的凭据和 Web 服务器上启用的身份验证方法,验证您是否有权查看此目录或页面。联系 Web 服务器的管理员以获得更多帮助。
回答by Jason
If you are using Visual Studio, you can also left-click on the project in Solution Explorerand change the Windows Authenticationproperty to Enabledin the Propertieswindow.
如果您在使用Visual Studio,你也可以用鼠标左键点击在该项目的解决方案资源管理器,并改变Windows身份验证属性,以启用在属性窗口。
回答by Ant Swift
The cause if had for this problem was IIS Express not allowing WindowsAuthentication. This can be enabled by setting
此问题的原因是 IIS Express 不允许 WindowsAuthentication。这可以通过设置启用
<windowsAuthentication enabled="true">
in the applicationhost.config file located at C:\Users[username]\Documents\IISExpress\config.
在位于 C:\Users[用户名]\Documents\IISExpress\config 的 applicationhost.config 文件中。
回答by Tony L.
回答by Daniel
Hosting on IIS Express: 1. Click on your project in the Solution Explorer to select the project. 2. If the Properties pane is not open, open it (F4). 3. In the Properties pane for your project: a) Set "Anonymous Authentication" to "Disabled". b) Set "Windows Authentication" to "Enabled".
在 IIS Express 上托管: 1. 在解决方案资源管理器中单击您的项目以选择该项目。2. 如果“属性”窗格未打开,请将其打开 (F4)。3. 在项目的属性窗格中: a) 将“匿名身份验证”设置为“已禁用”。b) 将“Windows 身份验证”设置为“已启用”。
回答by Leniel Maccaferri
In my case I had to open the file:
就我而言,我必须打开文件:
C:\...\Documents\IISExpress\config\applicationhost.config
I had this inside the file:
我在文件中有这个:
<authentication>
<anonymousAuthentication enabled="true" User="" />
I just removed the User=""part. I really don't know how this thing got there... :)
我刚刚删除了User=""部分。我真的不知道这东西是怎么到那里的... :)
Note: Make sure you have something like this in the end of applicationhost.config:
注意:请确保在末尾有这样的内容applicationhost.config:
.
.
.
<location path="MyCompany.MyProjectName.Web">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
</configuration>
You may also want to take a look here: https://stackoverflow.com/a/10041779/114029
您可能还想看看这里:https: //stackoverflow.com/a/10041779/114029
Now I can access the login page as expected.
现在我可以按预期访问登录页面。
回答by BillDarcy
In my case a previous run of my app from VS reserved the URL. I could see this by running in a console:
在我的情况下,之前从 VS 运行我的应用程序保留了 URL。我可以通过在控制台中运行来看到这一点:
netsh http show urlacl
to delete this reservation i ran this in an elevatedconsole:
要删除此保留,我在提升的控制台中运行了它:
netsh http delete urlacl http://127.0.0.1:10002/
I found these steps heresolved my problem.
我发现这些步骤在这里解决了我的问题。
I'm using VS2013
我正在使用 VS2013
回答by Serj Sagan
I had to run Visual Studio in Administrative Modeto get rid of this error.
我不得不运行 Visual StudioAdministrative Mode来消除这个错误。
回答by frogatto
I had also the same problem and finally I could overcame it.
我也有同样的问题,最后我可以克服它。
Solution Explorer→ Right click on project→ Properties→ Web tab→ Project Url
Solution Explorer→ Right click on project→ Properties→ Web tab→Project Url
I have chosen another port number, and every things became fine!
我选择了另一个端口号,一切都变得很好!
回答by Ryan C
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
转到控制面板 > 网络和 Internet > 网络连接
Right click on any secondary Wireless Network Connection you may have (mine was named Wireless Network Connection 2) and click 'Properties'.
右键单击您可能拥有的任何辅助无线网络连接(我的名为无线网络连接 2),然后单击“属性”。
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'.
取消选中“允许其他网络用户通过此计算机的 Internet 连接进行连接”框。
Hit OK > then Apply.
点击确定 > 然后应用。
Hope this helps!
希望这可以帮助!
回答by kfn
I opened my web.config file, and found and removed this section:
我打开了我的 web.config 文件,发现并删除了这一部分:
<authorization>
<deny users="?" />
</authorization>
and my site came up, but there are issuues with the authentication..
我的网站出现了,但是身份验证存在问题..


