遇到父子网站配置问题Asp.Net MVC

时间:2015-04-17 17:08:31

标签: asp.net-mvc configuration iis-7

我有一个Asp.Net MVC .Net 4.5 Web应用程序http://parent.com我最近必须创建一个子URL以使其像这样工作:http://parent.com/tadecide/

为了让子Web应用程序正常工作,我必须将其添加到父Web应用程序web.config。

<location path="." inheritInChildApplications="false">
    <system.web>...</system.web>
    <system.webServer>...</system.webServer>
</location>

我可以访问这两个网站,但我遇到的问题是http://parent.com它无法再访问网站的根文件夹,例如:图片,内容,脚本,因此只有文字在网站上没有加载图片,内容和脚本。

配置:Windows Server 2008 R2 Standard,IIS 7,父网站是Asp.Net MVC .Net 4.5,子网站是Asp.Net MVC .Net 4.5.1

我的http // parent.com的web.config位于

之下
<?xml version="1.0" encoding="UTF-8"?>
<!--
 For more information on how to configure your ASP.NET application, please     visit
  http://go.microsoft.com/fwlink/?LinkId=301879
 -->
<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=6.0.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>
<appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="MvcMailer.BaseURL" value="" />
    <add key="elmah.mvc.disableHandler" value="false" />
    <add key="elmah.mvc.disableHandleErrorFilter" value="false" />
    <add key="elmah.mvc.requiresAuthentication" value="true" />
    <add key="elmah.mvc.IgnoreDefaultRoute" value="true" />
    <add key="elmah.mvc.allowedRoles" value="Contractor" />
    <add key="elmah.mvc.allowedUsers" value="*" />
    <add key="elmah.mvc.route" value="Administrator/elmah" />
</appSettings>

<connectionStrings>
    <add name="MyMasterContext" connectionString="Data Source=.;Initial Catalog=MyCatalog;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<location path="." inheritInChildApplications="false">
    <system.web>
        <sessionState timeout="35" />
        <customErrors mode="RemoteOnly" redirectMode="ResponseRewrite" />
        <authentication mode="None" />
        <compilation targetFramework="4.5">
            <assemblies>
                <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                <add assembly="DevExpress.Web.ASPxThemes.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
                <add assembly="DevExpress.Web.ASPxHtmlEditor.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
                <add assembly="DevExpress.Web.Mvc5.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
                <add assembly="DevExpress.Utils.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
                <add assembly="DevExpress.Web.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
                <add assembly="DevExpress.Data.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
                <add assembly="DevExpress.Web.ASPxSpellChecker.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
                <add assembly="DevExpress.SpellChecker.v13.1.Core, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
            </assemblies>
        </compilation>
        <httpRuntime targetFramework="4.5" enableVersionHeader="false" maxRequestLength="15730" />
        <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.Routing" />
                <add namespace="System.Web.WebPages" />
                <add namespace="System.Collections.Generic" />
                <add namespace="System.Collections" />
                <add namespace="System.Drawing" />
                <add namespace="System.Web.UI.WebControls" />
                <add namespace="System.Text.RegularExpressions" />

                <add namespace="DevExpress.Utils" />
                <add namespace="DevExpress.Web.ASPxHtmlEditor" />
                <add namespace="DevExpress.Web.Mvc" />
                <add namespace="DevExpress.Web.Mvc.UI" />
            </namespaces>
        </pages>
        <httpModules>
            <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
            <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
            <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
            <add name="RemoveCustomHeader" type="RemoveCustomHeader" />
            <add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
        </httpModules>
        <machineKey validationKey="56A706A6B565B7C79FEC1E28E40AD3F589734320CC14BF85D5878FD6428D1E65F45C83EEDF29E7E1DE2C160070EB5D967AE0D1AF2D1925019BFF8D1C887DEAC0" decryptionKey="4B5A667F9B40CEDB280749D24F80A79F89176797EE54725B8C5DA5966269E383" validation="SHA1" decryption="AES" />
    </system.web>

    <system.webServer>
        <modules>
            <remove name="FormsAuthenticationModule" />
            <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" />
            <add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule, DevExpress.Web.v13.1, Version=13.1.11.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
        </modules>
        <handlers>
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <remove name="OPTIONSVerbHandler" />
            <remove name="TRACEVerbHandler" />
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
        <validation validateIntegratedModeConfiguration="false" />
        <httpProtocol>
            <customHeaders>
                <add name="X-Frame-Options" value="SAMEORIGIN" />
                <remove name="X-Powered-By" />
            </customHeaders>
        </httpProtocol>
    </system.webServer> 
</location>

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>
<entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
        <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
</entityFramework>
<system.net>
    <mailSettings>
        <smtp from="email@email.com">
            <network host="mail.server" enableSsl="true" port="25" defaultCredentials="false" userName="email@email.com" password="mypass" />
        </smtp>
    </mailSettings>
</system.net>
<elmah>
    <errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/Errors" />
    <security allowRemoteAccess="true" />
</elmah>

1 个答案:

答案 0 :(得分:0)

我想出来了。 在标签之后和我输入带有根文件夹名称

的标签之前
    <location path="Content">
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers accessPolicy="Script">
            <remove name="StaticFile" />
        </handlers>
    </system.webServer>
  </location>

  <location path="fonts">   
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers accessPolicy="Script,Read">
      <clear />
            <remove name="StaticFile" />
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read"/>
        </handlers>
    </system.webServer>
  </location>

  <location path="Images">  
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers accessPolicy="Script,Read">
            <remove name="StaticFile" />
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read"/>
        </handlers>
    </system.webServer>
  </location>

  <location path="Scripts"> 
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers accessPolicy="Script,Read">
            <remove name="StaticFile" />
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read"/>
        </handlers>
    </system.webServer>
  </location>