Root path isn't displaying "Front Page"

Topics: ASP.NET 2.0, Business Logic Layer, Controls
Aug 28, 2010 at 12:51 AM
Edited Aug 28, 2010 at 12:51 AM

Hello,

I don't know if this is a BlogEngine issue, or an IIS7 configuration issue, but I have a BlogEngine site hosted on a local computer on IIS7.  I've created a page that's flagged as the "Front Page", and it's displayed if I navigate to http://localhost/MySite/default.aspx but if I navigate to http://localhost/MySite/ I see the newest blog post.  I want the front page to show if only the root path is specified.

Thanks,

Gabe

Coordinator
Aug 29, 2010 at 2:30 PM

I think this is a new issue that has come up with ASP.NET 4.0.  I can reproduce it on my computer with IIS 7.5.  If the application pool is at 2.0, then the URL comes thru as having default.aspx in it (even when default.aspx is not in the URL).  But if I change the application pool to ASP.NET 4.0, default.aspx does not come thru in the URL (reported to ASP.NET).

At least this is true for "Request.RawUrl", but "Request.Path" does correctly show default.aspx even in ASP.NET 4.0.

For the front page check, BE is looking at RawUrl and not seeing default.aspx when under ASP.NET 4.0.

I would suggest changing the application pool from 4.0 to 2.0.

Aug 29, 2010 at 4:35 PM

I suspected that might be the issue.  Unfortunately the app pool has to be asp.net 4.0 due to other components of the site, since BlogEngine is something I've incorporated into a much larger project.  I created a simple workaround that gets the job done and should scale with whatever version of asp.net I use in the future.  I threw the following check into the OnLoad event handler for default.aspx:

if (BlogEngine.Core.Page.GetFrontPage() != null && Request.RawUrl.ToUpperInvariant().Equals(Utils.RelativeWebRoot.ToUpperInvariant()))
     Response.Redirect("~/default.aspx");

This ensures that UrlRewrite in BlogEngine.Core does its magic and loads the "Front Page".

Gabe