close
Simple Routing: Hide (Remove) .ASPX extension in URL in ASP.Net using URL Routing
In order to implement URL Routing we will need to register the routes that we need to use in our application.
In order to do that I have created a method named RegisterRoutes and it has been called inside the Application_Start event inside the Global.asax file. This method will allow us to add routes to handle so that we can create our own custom URLs.
C#
<system.web>
    <urlMappings enabled="true">
     <add url="~/XXXX" mappedUrl="~/Products/XXXX.aspx"/>
    </arlMappings>
</system.web>
 
 
----------------------------------------------------------------
 
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">
    void Application_Start(object sender, EventArgs e)
    {
        RegisterRoutes(RouteTable.Routes);
    }
   
    static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapPageRoute("Customers""Customers""~/Customers.aspx");
    }
</script>
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 amychang2014 的頭像
    amychang2014

    工作需要筆記

    amychang2014 發表在 痞客邦 留言(0) 人氣()