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:
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.
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.