URL Rewriting

spidergirl1979

New member
Joined
Jun 26, 2009
Messages
3
Programming Experience
3-5
I know there are many different ways to do URL rewriting, but I'm banging my head against a wall trying to figure out the method I should use for what I want it to do.

Occasionally, the company I work for will put on contests that will last a month and require a page housing a simple image that contains the details. Instead of creating all these one-off pages, I instead put the HTML content in a blob field in an SQL table (along with the URL) and the idea is that I will have a generic page that will grab the content based on the requested URL. This way here I don't have to create all of these one-off pages, and the maintenance factor is easier because I can simply delete the records from the table once the contest is over

Currently I have in my web.config:
VB.NET:
<customErrors mode="On" defaultRedirect="404.aspx">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="404.aspx" />
        </customErrors>

This will redirect any 404 errors to the 404.aspx page. The 404 page on load grabs the HttpContext.Current.Request("aspxerrorpath") to find out the URL that the user typed in and verifies it's a valid URL rewrite request by looking in the above mentioned table. If it's valid then it'll display the content.

All of this works fine except for one minor detail. In the address bar it says "http://mydomain.com/404.aspx?aspxerrorpath=RequestedPage.aspx". I want the URL to remain intact so it'll look like "http://mydomain.com/RequestedPage.aspx"

I've tried to put code in the Global.asax page for a Server.Transfer, but I keep getting a "Error Executing child request for 404.aspx" (or whatever page I happen to specify as my generic page for these URL rewrite content pages)

Any help would be greatly appreciated.
 
Same Problem with 404 message in rewritten url

I'm having the same problem.
Redirecting 404 errors to 404.aspx - parsing the url and then using server.transfer to go to page.aspx?p=xx
This works and has been working on other sites I've done except in this case the 404 errors is showing in the url

should show ... /test.aspx
but shows ..../404.aspx?aspxerrorpath=/test.aspx

the 404.aspx I'm using is a copy and paste from another site which works fine. This other site uses a 404 redirect in IIS
For the site I am having trouble with I have tried using the 404 redirect in IIS and also in the web.config - it works in both places but with the same issue as shown above.

Anyone have any ideas?
 
waddyaknow - figured it out
I had this problem in a site I did a while ago and finally found my notes on it

Need to use IIS for the 404 redirect
Then in IIS properties>Home Directory>Configuration> Select .aspx and check Verify that File Exists.

woohoo
 
Back
Top