This project is read-only.

HttpHandlers Not Working?

Topics: ASP.NET 2.0
Jan 1, 2009 at 5:07 AM
I recently setup BE running locally using SQLServer mode.  Everything works great locally: I'm running locally using XP with IIS v5.1.  My problem happens when I upload this to my hosting provider.  BE is the only thing I have on my site so there's no collision with anything else. 

When I watch the page load in Fiddler I'm seeing the following items get 404 errors when running in SQLServer mode.  It seems that when you run in SQLServer mode the app starts using dynamic handlers (like js.axd, WebResource.axd, and opensearch.axd).  I don't have these problems when I run in XML mode from my hosting provider because in XML it seems that these resources are given a hard coded path you're in XML mode.

These all give me a 404 error:

In other words, every request that involves an <httpHandlers> in my web.config doesn't seem to be get handled by the BlogEngine handlers.  My hosting provider is running my site with IIS 6, so I can't use the <system.webServer> configuration ideas that I've seen in other posts here to make sure that IIS is properly setting handlers.  Does anyone have any ideas of how to debug this?  Do I need to have my hosting provider go into IIS 6 and do anything to change configurations so that ASP.NET picks up these handlers?  Can this be track via IIS log files?

<?xml version="1.0"?>
        <sectionGroup name="BlogEngine">
            <section name="blogProvider" requirePermission="false" type="BlogEngine.Core.Providers.BlogProviderSection, BlogEngine.Core" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/>
        <blogProvider defaultProvider="DbBlogProvider">
                <add name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core"/>
                <add name="DbBlogProvider" type="BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core" connectionStringName="BlogEngine"/>
    <!-- configSource is not implemented in Mono.
    <connectionStrings configSource="sql.config" />
        <add name="LocalSqlServer" connectionString="dummy"/>
        <!-- Mono complains if LocalSqlServer isn't specified -->
        <add name="BlogEngine" connectionString="Data Source=ZZZ;User ID=ZZZ;Password=ZZZ;persist security info=False;initial catalog=ZZZ;" providerName="System.Data.SqlClient"/>
        <add key="BlogEngine.FileExtension" value=".aspx"/>
        <!-- You can e.g. use "~/blog/" if BlogEngine.NET is not located in the root of the application -->
        <add key="BlogEngine.VirtualPath" value="~/"/>
        <!-- The regex used to identify mobile devices so a different theme can be shown -->
        <add key="BlogEngine.MobileDevices" value="(nokia|sonyericsson|blackberry|samsung|sec\-|windows ce|motorola|mot\-|up.b|midp\-)"/>
        <!-- The name of the role with administrator permissions -->
        <add key="BlogEngine.AdminRole" value="Administrators"/>
        <!--This value is to provide an alterantive location for storing data.-->
        <add key="StorageLocation" value="~/App_Data/"/>
        <!--A comma separated list of script names to hard minify. It's case-sensitive. -->
        <add key="BlogEngine.HardMinify" value="blog.js,widget.js,WebResource.axd"/>
    <trace enabled="true" pageOutput="true" requestLimit="50" traceMode="SortByTime" />
    <compilation debug="true">
                <add assembly="System.Management, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Configuration, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Data, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Drawing, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Web, Version=, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                <add assembly="System.Xml, Version=, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="auto" uiCulture="auto"/>
        <httpRuntime enableVersionHeader="false" useFullyQualifiedRedirectUrl="true" maxRequestLength="16384" executionTimeout="3600" requestLengthDiskThreshold="16384"/>
        <machineKey validationKey="D9F7287EFDE8DF4CAFF79011D5308643D8F62AE10CDF30DAB640B7399BF6C57B0269D60A23FBCCC736FC2487ED695512BA95044DE4C58DC02C2BA0C4A266454C" decryptionKey="BDAAF7E00B69BA47B37EEAC328929A06A6647D4C89FED3A7D5C52B12B23680F4" validation="SHA1" decryption="AES"/>
        <authentication mode="Forms">
            <forms timeout="129600" name=".AUXBLOGENGINE" protection="All" slidingExpiration="true" loginUrl="~/login.aspx" cookieless="UseCookies"/>
        <pages enableSessionState="false" enableViewStateMac="true" enableEventValidation="true">
                <add namespace="Controls" tagPrefix="blog"/>
        <customErrors mode="Off">
            <error statusCode="404" redirect="~/error404.aspx"/>
        <membership defaultProvider="XmlMembershipProvider">
                <add name="XmlMembershipProvider" type="BlogEngine.Core.Providers.XmlMembershipProvider, BlogEngine.Core" description="XML membership provider" passwordFormat="Hashed"/>
                <add name="SqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="BlogEngine" applicationName="BlogEngine"/>
                <add name="DbMembershipProvider" type="BlogEngine.Core.Providers.DbMembershipProvider, BlogEngine.Core" passwordFormat="Hashed" connectionStringName="BlogEngine"/>
        <roleManager defaultProvider="XmlRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".BLOGENGINEROLES">
                <add name="XmlRoleProvider" type="BlogEngine.Core.Providers.XmlRoleProvider, BlogEngine.Core" description="XML role provider"/>
                <add name="SqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="BlogEngine" applicationName="BlogEngine"/>
                <add name="DbRoleProvider" type="BlogEngine.Core.Providers.DbRoleProvider, BlogEngine.Core" connectionStringName="BlogEngine"/>
        <siteMap defaultProvider="PageSiteMap" enabled="true">
                <add name="PageSiteMap" description="The site map provider that reads in the .sitemap XML files." type="BlogEngine.Core.Web.Controls.PageSiteMap, BlogEngine.Core"/>
                <add name="SecuritySiteMap" description="Used for authenticated users." type="System.Web.XmlSiteMapProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" securityTrimmingEnabled="true" siteMapFile="Web.sitemap"/>
            <add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule, BlogEngine.Core"/>
            <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core"/>
            <add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule, BlogEngine.Core"/>
            <add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule, BlogEngine.Core"/>
            <!--Remove the default ASP.NET modules we don't need-->
            <remove name="PassportAuthentication"/>
            <remove name="Profile"/>
            <remove name="AnonymousIdentification"/>
            <add verb="*" path="file.axd" type="BlogEngine.Core.Web.HttpHandlers.FileHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="image.axd" type="BlogEngine.Core.Web.HttpHandlers.ImageHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="syndication.axd" type="BlogEngine.Core.Web.HttpHandlers.SyndicationHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="sitemap.axd" type="BlogEngine.Core.Web.HttpHandlers.SiteMap, BlogEngine.Core" validate="false"/>
            <add verb="*" path="trackback.axd" type="BlogEngine.Core.Web.HttpHandlers.TrackbackHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="pingback.axd" type="BlogEngine.Core.Web.HttpHandlers.PingbackHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="opensearch.axd" type="BlogEngine.Core.Web.HttpHandlers.OpenSearchHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="metaweblog.axd" type="BlogEngine.Core.API.MetaWeblog.MetaWeblogHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="rsd.axd" type="BlogEngine.Core.Web.HttpHandlers.RsdHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="css.axd" type="BlogEngine.Core.Web.HttpHandlers.CssHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="js.axd" type="BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="rating.axd" type="BlogEngine.Core.Web.HttpHandlers.RatingHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="opml.axd" type="BlogEngine.Core.Web.HttpHandlers.OpmlHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="blogml.axd" type="BlogEngine.Core.Web.HttpHandlers.BlogMLExportHandler, BlogEngine.Core" validate="false"/>
            <add verb="*" path="sioc.axd" type="BlogEngine.Core.Web.HttpHandlers.Sioc, BlogEngine.Core" validate="false"/>
            <add verb="*" path="apml.axd" type="BlogEngine.Core.Web.HttpHandlers.Apml, BlogEngine.Core" validate="false"/>
            <add verb="*" path="foaf*.axd" type="BlogEngine.Core.Web.HttpHandlers.Foaf, BlogEngine.Core" validate="false"/>

Jan 1, 2009 at 5:30 AM
Don't know if you saw my message in the other thread, but did you get a chance to try unchecking "Enable HTTP Compression"?

The problem with the CSS handler was that (I think) your old settings when using the Xml provider didn't have the Trim Stylesheets option checked.  I'm guessing the other problems you're seeing now with the other handlers are probably also related to different settings with the Sql DB provider versus what you had with the Xml provider.

I'd first try unchecking Enable HTTP Compression, this may eliminate all the errors you're seeing, or at least the js.axd errors.  You could then optionally try unchecking Enable OpenSearch to see if that eliminates the 404 error with opensearch.axd.  You could then optionally try unchecking Compress WebResource.axd which may eliminate the 404 error with WebResource.axd.
Jan 1, 2009 at 5:56 AM
Yep, tried that, no luck.  I'm going to have my hosting provider check the log files.  I'm looking at this post on the IIS Forum:
This post mentions that checking the IIS logs and getting the exact sub-error message would help. This article shows what the sub-error messages might mean:

In the IIS forums they seem to always reiterate that you need to configure IIS with the extension mapped appropriately.  I get the feeling that my *.axd files are not mapped to go to ...\v2.0.50727\aspnet_isapi.dll. What's got me a little confused is that I didn't have to map this in my local IIS instance to get things working. But, maybe *.axd is mapped by default (my IIS) and my hosting provider has this set to not default to be mapped (maybe a security thing?).  Hopefully my provider can help me out.

Right now I'm trying to find out where in IIS to see/set the mappings.  I can't find it :<

Jan 1, 2009 at 6:39 AM
I highly doubt the .AXD mappings to aspnet_isapi.dll are not correct.  If you have direct access to IIS, then you would right-click on your website (in IIS), select Properties, go to the "Home Directory" tab, and click the "Configuration..." button to see the mappings.  I'm pretty sure your blog was using AXD file extensions (for WebResource.axd and js.axd) when you were using the Xml provider.  Changing to the Sql provider wouldn't cause the mappings to not work.

BTW, I noticed at your blog (, if I click on one of the post titles, I get 404 errors there too.  The Tag cloud works though.  Your first post, for example,

Gives a 404 error.  The path is a "virtual" path that the UrlRewrite httpmodule in BE is supposed to handle.  So it appears that your httpModules aren't working?  Hmm...  I'm not sure what's going on.  Is your website hosted in a subfolder or installed in a folder with some other application?  Just trying to think of what the problem might be ...
Jan 1, 2009 at 6:50 AM
Your web.config file looks exactly like the standard web.config that comes with BE 1.4.5.  I also see 404 errors for syndication.axd on your blog when clicking the Subscribe link.  When you switched to the SQL DB provider, you created the necessary DB tables by running the SQL script, I suppose.  Then you changed your web.config file to use the DbBlogProvider.  Did you change anything else on your website?  Maybe when you copied files from your local machine to your hosted site, something didn't get transferred right?  You could try reuploading your files ...
Jan 1, 2009 at 8:06 PM
My hosting provider went into IIS6 and unchecked 'File Must Exist' for the axd extension, this allows it to use the virtual http handlers in your web.config. 
Hopefully the thread will save others time.  Thanks Ben for all your posts, greatly appreciated.
Jan 1, 2009 at 11:40 PM
Thanks for sharing.  You probably will want to ask your hosting provider to also uncheck 'File Must Exist' for ASPX extensions too.  It looks like there are still 404 errors on the posts, which have an ASPX extension.
(still getting a 404 error)
Jan 2, 2009 at 3:31 AM
Yep,  the email's already sent :>

So Ben, I see your posts here a lot.  Are you on the dev team?  I didn't see your name on the "People" tab.
Jan 2, 2009 at 3:49 AM
Nope, not on the dev team.  I may ask to be on the dev team since I think I can contribute in several ways.  But for now, I'm just having fun exploring BE while helping others whenever I can.  This issue you are now resolving has been a good learning experience, for the both of us, I think!