Hi guys
I'm using a URLRewrite module to redirect certain URLs in my .net 2.0
website. However I am getting som really bizarre behaviour
public void UrlRewriter_BeginRequest(object sender, System.EventArgs e)
{
HttpApplication app = (System.Web.HttpApplication)sender;
string url = app.Request.RawUrl.ToLower();
//app.Context.RewritePath("/idtest.aspx?sid=" + GetStoryID(url)
+ "&url=" + GetTrimmed(url), false);
return;
if (url.EndsWith("/contactus/") || url.EndsWith("/contactus"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"contactus.aspx", false);
else if (url.Contains("/thepoint/exhibitions/stories/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"story.aspx?type=exb&sid=" + GetStoryID(url), false);
else if (url.Contains("jobs"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"story.aspx?type=job&sid=" + GetStoryID(url), false);
else if (url.Contains("stories"))
{
// We're looking at a story
// Find out what kind of story (Exhibitions / Project /
Publications / Take Part)
if (url.Contains("ourwork/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"/story.aspx?type=project&sid=" + GetStoryID(url), false);
else if (url.Contains("publications/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"/publications/default.aspx?pid=" + GetStoryID(url), false);
else if (url.Contains("takepart/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"/takepart/default.aspx?pid=" + GetStoryID(url), false);
else if (url.Contains("thepoint/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"/story.aspx?type=the_point", false);
else if (url.Contains("exhibitions/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"/story.aspx?type=exb&sid=" + GetStoryID(url), false);
}
else if (url.Contains("/ourwork/"))
{
// are we going to an aow home page?
if (url.Contains("communities/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=COM", false);
if (url.Contains("earlyyears/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=ELY", false);
if (url.Contains("education/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=EDU", false);
if (url.Contains("healthandwellbeing/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=HWB", false);
if (url.Contains("youthengagement/"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=YEN", false);
}
else if (url.EndsWith("/accessibility/") ||
url.EndsWith("/accessibility"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"accessibility.aspx", false);
else if (url.Contains("thepoint"))
{
// we're looking for a The Point based url, one of these
maybe?
// Otherwise ignore and send to Default.aspx
if (url.EndsWith("/cafe/default.aspx"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"story.aspx?type=cafe&sid=35", false);
else if (url.EndsWith("/exhibitions/current/default.aspx"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"story.aspx?type=curexb", false);
else if (url.EndsWith("/venuehire"))
app.Context.RewritePath(ConfigurationManager.AppSe ttings["BaseUrl"] +
"story.aspx?type=venue&sid=36", false);
}
}
The 5th line in that code is a "return;" left over from some testing. Odd
thing is, if I leave it in, the URL rewriter works. If i comment it out, the
code still works, except I get errors on my pages, because the ID returned
from GetStoryID is invalid.
I know that's a seperate issue, but I don't get why commenting out the
return would affect the code the way it is? I'd have expected it to be the
other way around.
Can someone please explain!?!
Thanks, Dan.