Click here to Skip to main content
15,849,829 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
See more:
I m unable to rewrite url, below in my code. kindly help me with this, where i made a mistake.

1. Global.asax

C#
void Application_Start(object sender, EventArgs e)
   {
       // Code that runs on application startup
       RegisterRoute(RouteTable.Routes);
   }
   public static void RegisterRoute(RouteCollection routeCollection)
   {
       routeCollection.MapPageRoute("Customer", "Customer/{Training}", "~/Customer.aspx");
   }

2. Default.aspx
ASP.NET
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Customer/Customer.aspx?Training=software">Customer</asp:HyperLink>

3. Customer.aspx.cs
C#
if (Page.RouteData.Values["Training"] != null)
           {
               string category = Page.RouteData.Values["Training"].ToString() ?? string.Empty;
               Label1.Text = category;
           }
Posted
Updated 27-May-13 3:02am
v2
Comments
Sunasara Imdadhusen 27-May-13 8:02am    
Are you getting any error?

1 solution

step -1 Put the below code in web.config

XML
<system.web>
        <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        -->
        <urlMappings enabled="true">
            <add url="~/About@123" mappedUrl="Default2.aspx"/>
        </urlMappings>



Step- 2 See the Button click

C#
protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/About@123");
    }
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900