Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpHandler generated content (axd file - bundling css/js) gives 404 error. Using Combres

I want to bundle and minify my JS/CSS files. To do this, i am using Combres.

I've set up the Combres solution on my local environment, and it works there. However, when I deploy my application to the IIS, it doesn't work. Um-hm. The url I try to access is http://www.mysite.com/combres.axd/siteJs/-1639413070/ .

I get an IIS 404 error: 404 - File or directory not found.

This is my setup.

Web.config:

<?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>

Rendered 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>

And when I enter a link, like http://www.mysite.com/combres.axd/siteJs/-1639413070/ , it gives the IIS 404 error.

I can get it to run by setting "defaultDebugEnabled" to false, but then of course, it doesn't work.

I've made sure the NetworkService / IISuser has full access to my folder.

Any ideas why my handler falls?

like image 619
Lars Holdgaard Avatar asked Oct 06 '22 07:10

Lars Holdgaard


1 Answers

I had the same problem. but i got it fixed by adding

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

to the system.webserver\modules , and

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

to System.webserver\handlers in my web.config

this did the job for me.

like image 88
Jacob Bager Avatar answered Oct 10 '22 03:10

Jacob Bager