I want to direct these 3 paths to the base path of the default url.
www.mysite.com/page1.aspx
www.mysite.com/page2.aspx
www.mysite.com/page3.aspx
I want to present these 3 pages in the address bar as follows: www.mysite.com
My asp.net project has only these 3 pages.
How to do this in asp.net 3.5 sp1 with IIS 6.0.
void Application_BeginRequest(object sender, EventArgs e)
{
switch (HttpContext.Current.Request.Url.AbsolutePath.ToLower())
{
case "/page1.aspx":
HttpContext.Current.RewritePath("~/default.aspx");
break;
case "/page2.aspx":
HttpContext.Current.RewritePath("~/default.aspx");
break;
case "/page3.aspx":
HttpContext.Current.RewritePath("~/default.aspx");
break;
}
}
An error occurred using this code:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /default.aspx
The problem is rewriting the url. It is looking for default.aspx file. The file default.aspx is missing. File page1.aspx.
Why is he looking for default.aspx? I just want to rewrite the path.
source
share