Documenting Blogengine install on IIS 7 hell

Topics: ASP.NET 2.0
Dec 17, 2008 at 6:48 PM
Edited Dec 19, 2008 at 5:27 PM
Like usual moving a site to an online server sucks, especially if there is url rewriting involved. I am going to document all the problems I run into for future reference and for others in the same boat.

BlogEngine Version: 1.4.5
Hosting: Reliablesite.net
Package: Shared Win 2008 IIS 7
Running in: 2.0 integrated pipeline mode


Problems

1. 
URL rewriting does not work for posts, categories, tags, etc... When you click on those items it returns a 404 error page.

Ans.   Well if you don't care about your page extension then make sure this is set to .aspx <add key="BlogEngine.FileExtension" value=".aspx"/>. Mine was set to .html intentionally and I intend to keep it that way. Thanks to Ben I got this working. Just add the bolded line in the web.config sample below. Note that this is for 2.0 integrated pipeline mode.

2.  This problem relates to the first if you are trying to get url rewriting to work. It was suggested that my site run in something called "2.0 integrated pipeline mode". For my hosting there is a dropdown box that has something like "none, 2.0, 2.0 integrated pipeline". When I selected "2.0 integrated pipeline" every page on my site returned a 500 error.

Ans.   This is a problem related to your <system.webServer> section in your web.config. I came across this thread and replaced my entire section with it.
System.WebServer settings  <-- This is missing some handlers, use the code below

Replace your entire System.webServer section with this:
Note: If you have additional handlers you must add those. I have laid them out in alphabetical order so it is easy to figure out which handlers you have. The handler code is in the blogengine core under Web -> Httphandlers. The name of the handler is the last portion of the path you use on your site (hit view source). as far as I know the path is the same as the name. The type is the path to the .cs class in the httphandler section of the Blogengine core.

<system.webServer>
    <modules>
      <remove name="Profile" />
      <remove name="AnonymousIdentification" />
      <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite" preCondition="managedHandler" />
      <add name="CompressionModule" type="BlogEngine.Core.Web.HttpModules.CompressionModule" preCondition="managedHandler" />
      <add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule" preCondition="managedHandler" />
      <add name="WwwSubDomainModule" type="BlogEngine.Core.Web.HttpModules.WwwSubDomainModule" preCondition="managedHandler" />
    </modules>
    <handlers>
      <!-- Add your custom redirect extension here. Used in conjuction with BlogEngine.FileExtension in web.config-->
       <add name="HtmlFiles" path="*.html" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="" />   
      <!-- Default Blogengine handlers -->
      <add name="apml.axd" path="apml.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.Apml" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="blogml.axd_" path="blogml.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.BlogMLExportHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="css.axd_" path="css.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.CssHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="file.axd_" path="file.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.FileHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="foaf.axd" path="foaf.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.Foaf" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="image.axd_" path="image.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.ImageHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="js.axd_" path="js.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="opensearch.axd_" path="opensearch.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.OpenSearchHandler" preCondition="integratedMode,runtimeVersionv2.0" />      
      <add name="opml.axd_" path="opml.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.OpmlHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="pingback.axd_" path="pingback.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.PingbackHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="rating.axd_" path="rating.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.RatingHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="rsd.axd_" path="rsd.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.RsdHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="sioc.axd" path="sioc.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.Sioc" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="sitemap.axd_" path="sitemap.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.SiteMap" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="syndication.axd_" path="syndication.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.SyndicationHandler" preCondition="integratedMode,runtimeVersionv2.0" />
      <add name="trackback.axd_" path="trackback.axd" verb="" type="BlogEngine.Core.Web.HttpHandlers.TrackbackHandler" preCondition="integratedMode,runtimeVersionv2.0" />
    </handlers>
<validation validateIntegratedModeConfiguration="false" />
    <security>
      <authentication>
        <basicAuthentication enabled="false" />
      </authentication>
    </security>
    <defaultDocument>
      <files>
        <clear />
        <add value="default.aspx" />
      </files>
    </defaultDocument>
    <httpRedirect enabled="false">
      <clear />
    </httpRedirect>
  </system.webServer>


This fixed a few issues. It fixed the 500 errors and it also mapped the .axd files properly - I was also getting 404 errors on those even after I set my extension .aspx.

3.   Trying to add a comment to a post does nothing. What do I mean? I mean when someone writes a comment and clicks the button to add it, it is like the button doesn't do anything, like there is no code to make it work.

Ans:  Fixed by adding additional httphandlers. One of the ones in the list above - probably js.axd one

4.   Clicking on one of those bbcode links by the comments does not work. When I click on it, it reloads the page (shouldn't do that) and it doesn't place the tags in there

Ans:  Fixed by adding additional httphandlers. One of the ones in the list above - probably js.axd one


5.   When I user click the button to post a comment, it just hangs on the ajax loader image and doesn't post the comment.
Ans:  <unresloved>??? I went back to test out a comment and now it all of a sudden just works. I'm not 100% confident this is fixed, so I am going to keep an eye on it.

I'm sure there will be many more problems, but I need to get these ones worked out first. If anyone knows how to fix any of these I would greatly appreciated it, thanks!


Update
1. Regular .html files (not blog posts, categories, etc... ending with .html) were returning an error stating that the DefaultHttpHandler is not supported in 2.0 intergrated pipeliine mode. I found that if you change it to StaticFileHandler, it works. I found this out when I went to verify a google sitemap using html file upload.




Coordinator
Dec 17, 2008 at 7:29 PM
As a test, I tried some of the things you were doing with the .HTML extension on Vista/IIS7.  I too was getting 500 server errors and other problems.  The blog I tested this with is running 1.4.5.12.

What did seem to work was the following.

(1) Switched to the classic pipeline mode.

(2) Configured the BlogEngine.FileExtension setting for .html.

(3) I mapped the .HTML extension to the .NET ISAPI module.  I did this with the IIS Manager tool, but after doing this, my web.config file got automatically updated.  The entire <system.webServer> section now looks like what's below.

After making these changes, all the posts now have an .HTML extension and they work.  I can add comments and use the [b] [i] etc. links.  I did notice that pages such as Archive and Contact still have an .ASPX extension.  So maybe the BlogEngine.FileExtension setting currently only applies to posts?  Not sure.

    <system.webServer>
        <handlers>
            <add name="HTML files" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
        </handlers>
    </system.webServer>
Dec 17, 2008 at 7:34 PM
Edited Dec 17, 2008 at 7:34 PM
Hi Ben, I am going to try that later. Right now I am using the .aspx extension and trying to get everything else to work I almost have everything working except for posting comments, it now seems to hang on the ajax loader.
Dec 17, 2008 at 7:56 PM
I copied that handler line into the system.webserver section and changed my extension .html, but it didn't work. I guess I would have to go back to running the site in classic mode, right now it is using 2.0 integrated pipeline. Does anyone know how to map .html or any other extension for IIS 7 running in integrated mode? I might fire tech support a question, but that is a long shot.
Coordinator
Dec 17, 2008 at 9:04 PM
Edited Dec 17, 2008 at 9:20 PM
I think I may have it working with HTML extensions in integrated mode.  It works if you add the line below as the first handler in the system.webServer section.

I was able to add this new handler to both the system.webServer section you posted in your first message, and it also works by adding it to the system.webServer section that comes with BE 1.4.5.12.

<add name="HtmlFiles" path="*.html" verb="*" type="System.Web.DefaultHttpHandler" resourceType="Unspecified" preCondition="integratedMode" />
Dec 17, 2008 at 10:17 PM
It is interesting how things just seem to work with some web hosts and with others they do not. It would be nice to see what the different server setups are that cause these differences.
I have installed BE on 2008 several times both in the root and in sub-directories as well as with integrated pipeline on and off. Everything (except known bugs) just works. Now running 1.4.5.13 (source build) and a theme dev setup with 1.4.5 (web release) personally with no issues.
Dec 17, 2008 at 10:33 PM
Edited Dec 17, 2008 at 10:51 PM
You did it Ben! Thank you very much!

I added this to the system.webserver and it works. I will update the config file in the first post. Thanks for going beyond the call of duty. I'm still waiting on reliable to even respond...

 <add name="HtmlFiles" path="*.html" verb="*" type="System.Web.DefaultHttpHandler" resourceType="Unspecified" preCondition="integratedMode" />


If you don't mind my asking what hosting service are you with Taylex? And what kind of settings do they use?
Dec 20, 2008 at 4:32 PM
Is it possible to upgrade the application to .NET 3.5 and then deploy it to IIS7 ?
Coordinator
Dec 20, 2008 at 4:54 PM
Yes, .NET 3.5 and .NET 2.0 both work with either IIS6 or IIS7.
Dec 20, 2008 at 5:40 PM
@kenpachi I have a reseller account with Reseller Choice. I use both Windows Server 2003 and 2008. I have no idea how they are actually setup. They use DotNetPanel on a server farm for their hosting control panel which was why I went with them to start with after closing my own hosting business.

Coordinator
Dec 20, 2008 at 9:15 PM
If you're in IIS7 integrated mode and getting any server errors using the default web.config file that comes with BE, one thing to try is completely remove the <httpHandlers> and <httpModules> sections.  If you're in integrated mode, these modules and handlers are already defined in the <system.webServer> section and could potentially cause conflicts.

I was just testing BE 1.4.5.14 and was initially getting HTTP Error 500.22, "An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode."   Removing the httpHandlers and httpModules sections as described on this page eliminated the error.
Dec 20, 2008 at 9:32 PM
@Ben - Does your 1.4.5.14 install report that it is 1.4.5.13? I just fired one up and it claims 1.4.5.13 in the footer.
Coordinator
Dec 20, 2008 at 9:37 PM
Taylex - yes, mine does too!  I hadn't noticed that.  It looks like that version number comes from AssemblyInfo.cs in the BE core.  I'll pass this info. onto Mads via his Contact page.  Good catch!
Dec 20, 2008 at 9:43 PM
My install also resulted in the 500 server error in IP mode. I upgraded the solution to 3.5 and uploaded the resultant web.config and all is right with the world. Of course turning off IP mode and unchecking trim style sheets worked as well.
Coordinator
Dec 20, 2008 at 9:52 PM
I passed the version number problem onto Mads.  Interestingly, his blog reports 1.4.5.14 in the footer :-)

A 3.5 upgrade to fix the 500 server error is an interesting approach.  It seems like there's a number of ways to get the configuration right depending on the environment.

I noticed 1.4.5.14 no longer has "<validation validateIntegratedModeConfiguration="false" />" in the system.webServer section.  I think this not being in there caused the 500.22 server error I hadn't seen in past versions like 1.4.5.13.
Dec 31, 2008 at 4:35 AM
Thanks kenpachi!  It seems that I've successfully changed setting to integrated pipeline without problem after making the changes you listed.
Jan 21, 2009 at 8:00 PM
Sometimes I get gibberish when accessing the blog; it would only happen the 1st time of a browser session, and then a refresh of the page would show the page correctly.  It doesn't happen everytime on the 1st time either, especially whenever I had Fiddler open to try to track it down.  

Anyone experienced anything similar?  My web.config pretty much looks like what's suggested in this thread, and I'm running IIS 7 in integrated pipeline.
Feb 15, 2009 at 7:28 PM
Genius!

I have been struggling, literally, the entire day with this, until I finally succumbed and emailed my webhost provider. 5 seconds later I stumbled upon this thread.
My domaine is running on Windows 2008 servers, and thus IIS 7. All I got from my efforts were 500 errors.

Then when, I added the above to my web.config, the entire thing worked right off.
So thank you!

This was exactly what I needed.
Feb 17, 2009 at 7:50 PM
Edited Feb 19, 2009 at 12:31 PM
I am a web.config n00b, and I'm not totally sure what my hosting specs are. I was having trouble with my BE 1.4.5:
Either javascripts weren't working
OR
pages wouldn't work.

By removing the httpmodules / httpHandlers I could get javascipt to work, but this made page links go to 404.

I solved it by adding the <system.webServer> section kenpachi posted (complete with the fixed http line that followed) Then I removed one line from the httpHandlers:

            <add verb="*" path="js.axd" type="BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler, BlogEngine.Core" validate="false"/>

This seems to have fixed the issue for me. The only new issue it has created is that I can't close widgets by the X button unless I restore that line of code.

Yes, this was total crap-shoot guessing that paid off ;) I'll call it an educated guess.
Mar 27, 2009 at 10:00 AM
Well, I hereby can confirm this is also the way to go if you still have BE 1.3.xx (like I do) that is hosted on, or as in my case, transfered to an IIS 7 webserver.
I just copied the complete <system.webServer> section kenpachi posted (see above), and this did the trick.

Thanks mate, I owe you one!