移动到VS 2012后,MVC3内部网应用程序未经授权

本文关键字:应用程序 内部网 授权 MVC3 VS 2012 移动 | 更新日期: 2023-09-27 18:00:22

我有一个MVC3内部网应用程序,最初是在VS 2010中开发的。我只是试着在一台运行VS 2012的新机器上打开它,但我得到了这个:

错误消息401.2.:未经授权:由于服务器配置,登录失败。验证您是否有查看此目录的权限或基于您提供的凭据和身份验证的页面方法。联系Web服务器的管理员以获得其他帮助。

它被配置为在本地IIS web服务器下运行(使用IIS express)。这个项目中有一个WCF服务,使用.svc文件,我可以很好地访问它。我只是在通过浏览器访问MVC网站时才收到这个错误。如果我将项目切换到使用Visual Studio Development Server,它似乎可以正常工作,但我必须在IIS Express下运行它,因为我需要能够远程访问网站以测试某些功能。

我必须在web.config或项目属性中做些什么才能使此项目在VS 2012中工作吗?

这是我的web.config 中的一个片段

<authentication mode="Windows" />
<authorization>
  <deny users="?" />
</authorization>
<profile>
  <providers>
    <clear />
    <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
  </providers>
</profile>
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
  <providers>
    <clear />
    <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
    <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
  </providers>
</roleManager>
<customErrors mode="Off" />
<httpModules>
  <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" />
</httpModules>

移动到VS 2012后,MVC3内部网应用程序未经授权

这个问题的答案解决了我的问题:

Windows身份验证不起作用

我只是简单地编辑了applicationhost.config文件以允许windows身份验证,并且该站点已在IISExpress:下启动并运行

<windowsAuthentication enabled="true">...</windowsAuthentication>