ASP.Net Base Href Problem
I use Base Href on all my sites. Now with ASP.NET, this is a problem — WebForms sitting in subdirectories don’t work. Let’s say you have a form /dir/register.aspx and you have a button there that does something. Clicking on the button gives you a server error because it takes you back to “/register.aspx”. The base-href tag is the reason this confusion takes place.
To solve this, the simplest way would be to call this function on Page_Load() of all webforms sitting in sub-directories:
public void FixBaseJS()
{
string fixbasejs = @"script language=""javascript"">
document.forms[0].action = '" + this.Request["Url"] +
"?" + this.Request["Query_String"] + @"';
/script>";
RegisterClientScriptBlock("fixbasejs", fixbasejs);
}
Remember to prefix a < mark before the script and /script tags found in the fixbasejs function above.


Clever! We are tackling the same issue here.
I’d be interested in pointers to any “complicated” solutions that work without JavaScript?