Welcome Guest
Login Register
 
URL Rewriting Using ASP.NET C sharp.NET Web Site
 
0 Reply's, Recent Post by Tech on 6/30/2017 11:50:32 AM
   

Previous Thread     Next Thread

Tech
9 Points
51 Posts
      Reply            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
URL Rewriting files



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


   
   

    Click to Visit Profile Home
       

         Click to Visit Index 2 Page
   

   



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


   
   

        Click to Get User Details
   

   


 
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


URL Rewriting Video

   Previous Thread     Next Thread