RewitePath on IIS7 with .Net 3.5 or 4.0 - The resource cannot be found.
Posted
by
Renso
on Stack Overflow
See other posts from Stack Overflow
or by Renso
Published on 2011-03-01T23:23:31Z
Indexed on
2011/03/01
23:24 UTC
Read the original article
Hit count: 179
In Global.asax handle errors by trying to redirect users to another page without changing the url in the address bar, that's why I am using RewritePath and not Redirect.
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Context.RewritePath("~/Error.aspx", false);
}
Error.apsx in same root folder as About.aspx, and Default.aspx pages which of course work. Not sure I am having this issue.
Have the following web.config file settings that I thought may be relevant:
IIS7 settings: Application "TestRewriteUrl" under Default Web Site on DefaultAppPool.
This example my seem trivial but I cannot use IIS7 HTTP Redirect as I actually was using this example to keep it simple. What I want to ultimately do is have a user type in http://www.somesite.com/myownpage
and have it rewrite the path to another page in the same application directory by looking up the "myownpage" in the database to see what database id they have and redirect them to the correct "microsite" based on that without the user noticing a url change. Kind of like when you go to a blogging engine and no matter where in your blog you go the url remains the same. I don't want the user to go from http://www.mysite.com/tomshardware
to http://www.mysite.com?id=8734656856
. So that is why I used the simply example above to try and understand why the rewrite path does not work.
© Stack Overflow or respective owner