Bizarre "return" behaviour in HTTPModule

M

musosdev

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.AppSettings["BaseUrl"] +
"contactus.aspx", false);
else if (url.Contains("/thepoint/exhibitions/stories/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"story.aspx?type=exb&sid=" + GetStoryID(url), false);
else if (url.Contains("jobs"))

app.Context.RewritePath(ConfigurationManager.AppSettings["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.AppSettings["BaseUrl"] +
"/story.aspx?type=project&sid=" + GetStoryID(url), false);
else if (url.Contains("publications/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"/publications/default.aspx?pid=" + GetStoryID(url), false);
else if (url.Contains("takepart/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"/takepart/default.aspx?pid=" + GetStoryID(url), false);
else if (url.Contains("thepoint/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"/story.aspx?type=the_point", false);
else if (url.Contains("exhibitions/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["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.AppSettings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=COM", false);
if (url.Contains("earlyyears/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=ELY", false);
if (url.Contains("education/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=EDU", false);
if (url.Contains("healthandwellbeing/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=HWB", false);
if (url.Contains("youthengagement/"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"ourwork/aowhome.aspx?aow=YEN", false);
}
else if (url.EndsWith("/accessibility/") ||
url.EndsWith("/accessibility"))

app.Context.RewritePath(ConfigurationManager.AppSettings["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.AppSettings["BaseUrl"] +
"story.aspx?type=cafe&sid=35", false);
else if (url.EndsWith("/exhibitions/current/default.aspx"))

app.Context.RewritePath(ConfigurationManager.AppSettings["BaseUrl"] +
"story.aspx?type=curexb", false);
else if (url.EndsWith("/venuehire"))

app.Context.RewritePath(ConfigurationManager.AppSettings["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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top