5

我想捆绑和缩小我的 JS/CSS 文件。为此,我正在使用 Combres

我已经在我的本地环境中设置了 Combres 解决方案,它在那里工作。但是,当我将应用程序部署到 IIS 时,它不起作用。嗯。我尝试访问的网址是http://www.mysite.com/combres.axd/siteJs/-1639413070/

我收到 IIS 404 错误:404 - File or directory not found

这是我的设置。

网络配置:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  <section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
    <section name="combres" type="Combres.ConfigSectionSetting, Combres, Version=2.2, Culture=neutral, PublicKeyToken=1ca6b37997dd7536" />
  </configSections>
  <appSettings>
    <add key="ChartImageHandler" value="storage=session;timeout=20;"/>
        <add key="CombresSectionName" value="combres" />
  </appSettings>

  <system.web>
    <httpModules>
      <add name="MinifyHtml" type="GKBusiness.HtmlMinifier.MinifyHtmlClass,GKBusiness"/>
    </httpModules>
    <globalization culture="da-DK" uiCulture="da-DK"/>
    <httpHandlers>
        <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
        <add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />

    </httpHandlers>
    <pages controlRenderingCompatibilityVersion="4.0" enableViewState="true">
      <controls>
        <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </controls>
      <namespaces>
        <add namespace="Combres"/>
      </namespaces>
    </pages>
    <compilation debug="false" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </assemblies>
    </compilation>


    <httpRuntime requestValidationMode="2.0"/>

  </system.web>
  <system.webServer>
    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
      <dynamicTypes>
        <add mimeType="text/*" enabled="true"/>
        <add mimeType="message/*" enabled="true"/>
        <add mimeType="application/javascript" enabled="true"/>
        <add mimeType="*/*" enabled="false"/>
      </dynamicTypes>
      <staticTypes>
        <add mimeType="text/*" enabled="true"/>
        <add mimeType="message/*" enabled="true"/>
        <add mimeType="application/javascript" enabled="true"/>
        <add mimeType="*/*" enabled="false"/>
      </staticTypes>
    </httpCompression>
    <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="MinifyHtml" type="GKBusiness.HtmlMinifier.MinifyHtmlClass,GKBusiness"/>
    </modules>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
      <remove name="ChartImageHandler"/>
      <add name="AjaxToolkit" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" />
    </handlers>


  <log4net>
    <appender name="File" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="Logs\\log_%date{yyyyMMdd}.txt"/>
      <appendToFile value="true"/>
      <rollingStyle value="Date"/>
      <datePattern value="yyyyMMdd"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"/>
      </layout>
      <filter type="log4net.Filter.LevelRangeFilter">
        <param name="LevelMin" value="INFO"/>
        <param name="LevelMax" value="OFF"/>
      </filter>
    </appender>
    <logger name="File">
      <level value="All"/>
      <appender-ref ref="File"/>
    </logger>
    <root>
      <level value="ALL"/>
      <appender-ref ref="File"/>
    </root>
  </log4net>

    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Fasterflect" publicKeyToken="38d18473284c1ca7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.1.2.0" newVersion="2.1.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="AjaxMin" publicKeyToken="21ef50ce11b5d80f" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.48.4489.28432" newVersion="4.48.4489.28432" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <dotless minifyCss="false" cache="true" web="false" />
  <combres definitionUrl="~/App_Data/combres.xml" />
</configuration>

Combres.xml:

<combres xmlns='urn:combres'>
  <filters>
    <filter type="Combres.Filters.FixUrlsInCssFilter, Combres" />
  </filters>
  <resourceSets url="~/combres.axd"
                defaultDuration="30"
                defaultVersion="auto"
                defaultDebugEnabled="auto"
                defaultIgnorePipelineWhenDebug="true"
                localChangeMonitorInterval="30"
                remoteChangeMonitorInterval="60"
                >
    <resourceSet name="siteCss" type="css">
      <resource path="~/Resources/Plugins/bootstrap.min.css" />
      <resource path="~/Resources/Plugins/bootstrap-responsive.min.css" />
      <resource path="~/Resources/Styles/jquery-ui.css" />
      <resource path="~/Resources/Styles/screen.css" />

    </resourceSet>
    <resourceSet name="siteJs" type="js">
      <resource path="~/Resources/Plugins/bootstrap.min.js" />
      <resource path="~/Resources/Plugins/TagIt/js/tag-it.js" />
    </resourceSet>
  </resourceSets>
</combres>

呈现的 HTML:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
    <link rel="stylesheet" type="text/css" href="/combres.axd/siteCss/-489484553/"/><script type="text/javascript" src="/combres.axd/siteJs/-1639413070/"></script>

当我输入一个链接时,比如http://www.mysite.com/combres.axd/siteJs/-1639413070/,它会给出 IIS 404 错误。

我可以通过将“defaultDebugEnabled”设置为 false 来运行它,但是当然,它不起作用。

我已确保 NetworkService / IISuser 对我的文件夹具有完全访问权限。

任何想法为什么我的处理程序会摔倒?

4

2 回答 2

4

我有同样的问题。但我通过添加来修复它

<add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

到 system.webserver\modules ,和

<add name="UrlRoutingHandler" path="UrlRouting.axd"  type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral,  PublicKeyToken=b03f5f7f11d50a3a" verb="*"/>

到我的 web.config 中的 System.webserver\handlers

这为我完成了工作。

于 2013-01-21T10:51:06.940 回答
0

我想我想通了。当我从开发到生产时遇到了同样的问题。

我将路由模块添加到 system.web\httpModules 列表中。这使我的解决方案起作用。

于 2013-02-12T14:29:45.030 回答