bug in urlrewrite

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

Hi:

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

The file "UrlRewrite.cs" should be updated.

//from
				else if (url.Contains("/AUTHOR/"))
				{
					string author = ExtractTitle(context, url);
					context.RewritePath(Utils.RelativeWebRoot + "default" + BlogSettings.Instance.FileExtension + "?name=" + author + GetQueryString(context), false);
				}
//to
else if (url.Contains("/AUTHOR/"))
				{
					string author = ExtractTitle(context, url);
					context.RewritePath(Utils.RelativeWebRoot + "default.aspx?name=" + author + GetQueryString(context), false);
				}
Coordinator
Mar 18, 2010 at 7: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 8: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.

Coordinator
Mar 18, 2010 at 10: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.