I need to access the same page via two different names for the page.
Example:
CustomersDetail.aspx
needs to be accessable using the aliased name PartnersDetail.aspx
CustomersDetail.aspx is the real file.
Both of the following urls should map to the same page:
http://www.example.com/CustomersDetail.aspx
http://www.example.com/PartnersDetail.aspx
Is this possible using the Web.Config? If this is possible can the page know which url it was accessed from by looking that the request uri?
4GuysFromRolla does an excellent job of explaining ASP.NET 2.0's method of url mapping within the web.config which allows for very readable and easily maintainable url mapping.
Essentially you will want to put the following in your web.config inside of the system.web section:
<urlMappings enabled="true">
<add url="~/PartnersDetail.aspx" mappedUrl="~/CustomersDetail.aspx" />
</urlMappings>
Depeding on the version of the .Net Framework (introduced in 3.5) you are using you could add an entry to the RouteTable.Routes collection in the Global.asax on application start:
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("DetailReRoute",
"PartnersDetail.aspx", //Virtual Page
"~/CustomersDetail.aspx", //Physical Page
false, null, null);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With