Can an ASPX page get an alias so that it can be accessed from two different URLs?

I need to access one page through two different page names.

Example:

CustomersDetail.aspx must be accessible using aliases PartnersDetail.aspx

CustomersDetail.aspx is a real file.

Both of the following URLs should appear on the same page:

http://www.example.com/CustomersDetail.aspx    
http://www.example.com/PartnersDetail.aspx

Is this possible with Web.Config? If possible, can the page find out which URL it accessed by looking at that uri request?

+5
source share
4 answers

4GuysFromRolla URL- URL- ASP.NET 2.0 web.config, URL-.

, web.config system.web:

<urlMappings enabled="true">
  <add url="~/PartnersDetail.aspx" mappedUrl="~/CustomersDetail.aspx" />
</urlMappings>
+7

.Net Framework ( 3.5), , RouteTable.Routes Global.asax :

    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);
    }
+3

, , URL-, Response.Redirect( - CustomersDetail. aspx - URL-) Server.Transfer( , URL http://www.example.com/PartnersDetail.aspx ) Page_Load?

+1

UserControls .

, UserControl. UserControl . , , UserControl, .

I know this is not the best solution, but it works well if you want to go directly to aspx pages.

+1
source

All Articles