Monday 29 August 2016

URL Rewriting in Asp.Net 3.5 and newer to 3.5

 
 
RouteCollection.MapPageRoute method, it has 5 overloads. These are:
1. MapPageRoute(String<routeName>, String<routeUrl>, String<physicalFile>)
2. MapPageRoute(String<routeName>, String<routeUrl>, String<physicalFile>),Boolean<checkPhysicalUrlAccess>)
3. MapPageRoute(String<routeName>, String<routeUrl>, String<physicalFile>, Boolean<checkPhysicalUrlAccess>, RouteValueDictionary<defaults>)
4. MapPageRoute(String<routeName>, String<routeUrl>, String<physicalFile>, Boolean<checkPhysicalUrlAccess>, RouteValueDictionary<defaults>, RouteValueDictionary<constraints> )
5. MapPageRoute(String<routeName>, String<routeUrl>, String<physicalFile>), Boolean<checkPhysicalUrlAccess>, RouteValueDictionary<defaults>), RouteValueDictionary<constraints>, RouteValueDictionary<dataTokens>)
 
 
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using System.Web.Security;
using System.Web.SessionState;
namespace URLRewriting
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
static void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("My-Post", "My-Post", "~/mypost.aspx");
routes.MapPageRoute("My-Blog", "My-Blog/{Key}", "~/User/myblog.aspx");
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
}
}

No comments :