ASP.NET MVC4配置为不列出此目录错误的内容

时间:2016-02-11 13:36:49

标签: asp.net-mvc-4 iis webdeploy

我在这方面的斗智斗勇。我有一个ASP.NET MVC4 Web应用程序。我试图在Windows 7 Ultimate 64位机器上进行设置。到目前为止,我已经安装了IIS(版本7.5),通过Visual Studio生成的.zip文件安装了我的Web应用程序并安装了ASP.NET MVC 4.我已将我的网页指向.NET 4应用程序池。但是,每次我尝试访问该页面时,都会给出以下错误:

enter image description here 我尝试在命令提示符下运行以下内容,因为它在过去解决了我的问题(来自HTTP Error 403.14 - Forbidden - The Web server is configured to not list the contents of this directory):

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

但它似乎没有做任何事情 - 它只列出了所有命令行选项。 我注意到,在已安装的应用程序列表中,它缺少Microsoft ASP.NET MVC 4运行时(这在我的另一台机器上存在)。这有必要让这个工作吗?如果是这样,我该如何安装呢?运行ASP.NET MVC4安装程序不会添加它。  enter image description here 这是我在Windows功能中启用的功能:  enter image description here 谁能帮助我指出正确的方向?谢谢。我已经附加了我的web.config,但我认为问题更多的是让ASP.NET MVC4工作。

              <configuration>
            <configSections>
            <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
            <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
            <sectionGroup name="elmah">
            <section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
            <section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
            <section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
            <section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
            </sectionGroup>
            </configSections>
            <connectionStrings>
            <add name="ConnectDataContextConnectionString" connectionString="User Id=connectadmin;Password=letme1n;Host=ws2012e;Database=cl_svhstest;Persist Security Info=True;Found Rows=true;" />
            <add name="DBKey" connectionString="Driver={MySQL ODBC 3.51 Driver};User Id=connectadmin;Password=letme1n;Server=ws2012e;Database=cl_svhstest;Option = 3;Persist Security Info=True;Found Rows=true;" />
            <add name="ClTeleceteraDataContextConnectionString" connectionString="User Id=sa;Password=letme1n;Host=ws2012e;Database=cl_telecetera;Persist Security Info=True" />
            <add name="DefaultConnection" connectionString="DefaultConnection_ConnectionString" providerName="System.Data.SqlClient" />
            </connectionStrings>
            <appSettings>
            <add key="webpages:Version" value="2.0.0.0" />
            <add key="webpages:Enabled" value="true" />
            <add key="PreserveLoginUrl" value="true" />
            <add key="ClientValidationEnabled" value="true" />
            <add key="UnobtrusiveJavaScriptEnabled" value="true" />
            <add key="dhx_license" value="dan@telecetera.co.uk-enterprise--aHEjuRAwNm9yY7e7q4uR8P08+A1oBBK/aVgjzekJJdXuvReGeoKI+s3A0CcdEC0tXutD7y4okCfkA8OsRGdIww==" />
            <add key="elmah.mvc.disableHandler" value="false" />
            <add key="elmah.mvc.disableHandleErrorFilter" value="false" />
            <add key="elmah.mvc.requiresAuthentication" value="false" />
            <add key="elmah.mvc.IgnoreDefaultRoute" value="false" />
            <add key="elmah.mvc.allowedRoles" value="*" />
            <add key="elmah.mvc.allowedUsers" value="*" />
            <add key="elmah.mvc.route" value="elmah" />
            </appSettings>
            <location path="">
            <system.web>
            <authorization>
            <deny users="?" />
            </authorization>
            </system.web>
            </location>
            <location path="api">
            <system.web>
            <authorization>
            <allow users="*" />
            </authorization>
            </system.web>
            </location>
            <location path="content">
            <system.web>
            <authorization>
            <allow users="*" />
            </authorization>
            </system.web>
            </location>
            <location path="scripts">
            <system.web>
            <authorization>
            <allow users="*" />
            </authorization>
            </system.web>
            </location>
            <system.web>
            <trust level="Full" />
            <roleManager enabled="true" />
            <customErrors mode="Off" />
            <compilation targetFramework="4.0" />
            <authentication mode="Forms">
            <forms loginUrl="~/Login/Index" defaultUrl="~/Login/Index" timeout="10080" />
            </authentication>
            <pages controlRenderingCompatibilityVersion="4.0">
            <namespaces>
            <add namespace="System.Web.Helpers" />
            <add namespace="System.Web.Mvc" />
            <add namespace="System.Web.Mvc.Ajax" />
            <add namespace="System.Web.Mvc.Html" />
            <add namespace="System.Web.Optimization" />
            <add namespace="System.Web.Routing" />
            <add namespace="System.Web.WebPages" />
            </namespaces>
            </pages>
            <httpModules>
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
            <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
            </httpModules>
            <httpRuntime maxQueryStringLength="32768" maxRequestLength="1048576" executionTimeout="3600" />
            </system.web>
            <system.webServer>
            <modules runAllManagedModulesForAllRequests="true">
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
            <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
            </modules>
            <security>
            <requestFiltering>
            <requestLimits maxAllowedContentLength="1073741824" maxQueryString="32768" />
            </requestFiltering>
            </security>
            <httpErrors errorMode="Detailed" />
            <asp scriptErrorSentToBrowser="true" />
            <validation validateIntegratedModeConfiguration="false" />
            </system.webServer>
            <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
            </dependentAssembly>
            <dependentAssembly>
            <assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.0.66.0" newVersion="1.0.66.0" />
            </dependentAssembly>
            <dependentAssembly>
            <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-6.7.4.0" newVersion="6.7.4.0" />
            </dependentAssembly>
            <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
            </dependentAssembly>
            <dependentAssembly>
            <assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
            </dependentAssembly>
            </assemblyBinding>
            </runtime>
            <entityFramework>
            <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
            </entityFramework>
            </configuration>

1 个答案:

答案 0 :(得分:0)

我终于通过卸载IIS,再次运行.NET framework 4.5安装程序(选择修复模式)然后重新安装IIS来实现它。然后当我添加我的应用程序时,它工作。我浪费了几个小时,希望这有助于其他人!