bug in urlrewrite

Topics: Business Logic Layer
Mar 18, 2010 at 4:04 AM


i found a bug when changed BlogEngine.FileExtension in web.config

The file "UrlRewrite.cs" should be updated.

				else if (url.Contains("/AUTHOR/"))
					string author = ExtractTitle(context, url);
					context.RewritePath(Utils.RelativeWebRoot + "default" + BlogSettings.Instance.FileExtension + "?name=" + author + GetQueryString(context), false);
else if (url.Contains("/AUTHOR/"))
					string author = ExtractTitle(context, url);
					context.RewritePath(Utils.RelativeWebRoot + "default.aspx?name=" + author + GetQueryString(context), false);
Mar 18, 2010 at 8:39 AM

Is the original code not functioning correctly?

BlogSettings.Instance.FileExtension is used to optionally allow people to use custom extensions -- rather than hard coding .ASPX.  If you have the following appSetting in your web.config file (which is there by default), then BlogSettings.Instance.FileExtension will resolve to .ASPX at runtime.

<add key="BlogEngine.FileExtension" value=".aspx"/>

Mar 18, 2010 at 9:12 AM

if the FileExtension is aspx,

when rewriting, the string 

Utils.RelativeWebRoot + "default" + BlogSettings.Instance.FileExtension + "?name="
is "....default.aspx?name..." 
It is ok.
But if you change it to another extension,such as "html", the string would be "default.html?name=..."
In fact,the file does not exist, and there is no other url rewrite module to deal with it. so it is a bug.

Mar 18, 2010 at 11:06 AM

This particular appSetting is an advanced setting for people who want to use a different extension such as HTML.  In this case, the advanced user needs to configure IIS so HTML requests are handled by ASP.NET so BE's UrlRewrite module can handle the request.  Other advanced users might use a different extension.

This is not the only place in BE that uses BlogSettings.Instance.FileExtension.  Other parts of the code also use it.

99% of BE users are not interested in taking advantage of this advanced setting.  That is fine because they just leave the default .ASPX appSetting alone.  And everything runs fine.

It's not a bug if software offers an advanced setting and a person enters an invalid value for the setting.  That's just a case of mis-using the advanced setting.