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>
<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>
全站熱搜