Report Abuse |
URL Rewriting Using ASP.NET C sharp.NET Web Site 6/30/2017 11:50:32 AM
URL Rewriting Using ASP.NET C#.NET Web Site
Blow Screen shot of ASP.NET C#.net Web Site
Global.asax
void Application_Start(object sender, EventArgs e)
{
RegisterRoute(System.Web.Routing.RouteTable.Routes);
}
public static void RegisterRoute(System.Web.Routing.RouteCollection routes)
{
routes.MapPageRoute("ForProfile", "Profile/ProfileHome", "~/Profile/ProfileHome.aspx");
routes.MapPageRoute("ForIndex2", "index_2", "~/index2.aspx");
routes.MapPageRoute("ForUserDetails", "Profile/UserDetails/{EMPID}", "~/Profile/UserDetails.aspx");
}
index.aspx
Below Design Code
Below Code behind code for index.aspx
public partial class index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lnkFirstLink.HRef = Page.GetRouteUrl("ForProfile", new { });
lnkIndex2.HRef = Page.GetRouteUrl("ForIndex2", new { });
}
}
index2.aspx
Design code
Welcome to Index 2 Page
Profile/ProfileHome.aspx
public partial class Profile_ProfileHome : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lnkEmployee.HRef = Page.GetRouteUrl("ForUserDetails", new { EMPID = "10" });
}
}
Profile/UserDetails.aspx
public partial class Profile_UserDetails : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String Empid= Page.RouteData.Values["EmpID"] as String;
Label1.Text = "Employee iD" + Empid;
}
}
For More details watch below Video
|