473,395 Members | 1,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Bizarre "return" behaviour in HTTPModule

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.
Jul 1 '08 #1
0 1265

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following...
1
by: yingjian.ma1955 | last post by:
When I want to disable the select functionality, Can I just use onselectstart="return false"? I tried it and it works. But it seems people always put onselectstart="return false"...
32
by: Mike Machuidel | last post by:
Hi, I'm a game developer programming mostly in C and ASM for about 7 years. Today at work a colleague (a C++ programmer) yelled at me I'm a bad C programmer because I use "return(0);" instead...
10
by: LaEisem | last post by:
On-the-job, I have "inherited" a lot of old C language software. A question or two about when "casting" of null pointer constants is needed has occurred during behind-the-scenes cleanup of some...
0
by: Joeyej | last post by:
Hi - I'm trying to move/use a web form (containing some javascript field checks) previously hosted on a Windows 2000 server. However, the FORM METHOD="post..." command in the form (shown below)...
13
by: kurtj | last post by:
Hello Gurus: I have a validation script (below) that is somehow messed up. If the Name field is blank, I get the alert message, then the browser window goes to a blank document with the word...
38
by: looping | last post by:
For Python developers around. >From Python 2.5 doc: The list of base classes in a class definition can now be empty. As an example, this is now legal: class C(): pass nice but why this...
0
by: Dan D. | last post by:
We are running an IIS Server on W2K3 Server. We have 20 or 30 ASP.NET 1.1 applications. Recently I have converted an existing 1.1 application to use the 2.0 framework. After testing and a little...
3
by: Poster28 | last post by:
What would you suggest to check python programs for non-syntax error. One example I could think of that one might forget to "return" a value from a function. How could I check for these and...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.