Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:59:04+00:00 2026-06-14T19:59:04+00:00

I am creating asp.net web application with web forms, I am using register routes

  • 0

I am creating asp.net web application with web forms, I am using register routes to product friendly URL’s.

Following is the code in Global.asax.cs;

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}

    void RegisterRoutes(RouteCollection routes)
    {
        // Register a route for Categories/All
        routes.MapPageRoute(
           "All Categories",      // Route name
           "Categories/All",      // Route URL
           "~/AllCategories.aspx" // Web page to handle route
        );

        // Route to handle Categories/{CategoryName}. 
        // The {*CategoryName} instructs the route to match all content after the first slash, which is needed b/c some category names contain a slash, as in the category "Meat/Produce"
        // See http://forums.asp.net/p/1417546/3131024.aspx for more information
        routes.MapPageRoute(
           "View Category",               // Route name
           "Categories/{*CategoryName}",  // Route URL
           "~/CategoryProducts.aspx"      // Web page to handle route
        );
        // Register a route for Products/{ProductName}
        routes.MapPageRoute(
           "View All Product",           // Route name
           "Products", // Route URL
           "~/ViewProducts.aspx"      // Web page to handle route
        );


        // Register a route for Products/{ProductName}
        routes.MapPageRoute(
           "View Product",           // Route name
           "Product/{ProductName}", // Route URL
           "~/ViewProduct.aspx"      // Web page to handle route
        );


        // Register a route for Products/{ProductName}
        routes.MapPageRoute(
           "Add Product",           // Route name
           "NewProduct", // Route URL
           "~/AddProduct.aspx"      // Web page to handle route
        );


    }

Now in one page when I put

        lnkNewProduct.NavigateUrl = Page.GetRouteUrl("Add Product");

It produce wrong href url when I run the project.

Can anyone please tell why this happen? At moment it is showing URL like http:\localhost:5770\Categories\All?Length=11… this is hard to understand.

Any hint or help???

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:59:05+00:00Added an answer on June 14, 2026 at 7:59 pm

    You need to use the correct overload:

    Page.GetRouteUrl("Add Products", null);
    

    This GetRouteUrl overload uses the RouteName.

    You can use Route Url expressions also:

    http://msdn.microsoft.com/en-us/library/system.web.compilation.routeurlexpressionbuilder.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my asp.net web application, I'm using asp.net forms authentication with following configuration. <authentication
I am creating a web application using Form Authentication of Asp.Net with C# and
I am creating a Web application using ASP.NET MVC, and I'm trying to use
I'm using the Entity Framework for an ASP.NET Web Forms application and I'm wondering
I am creating an ASP.NET Web forms application with MVP pattern. The structure of
I am thinking about creating my new asp.net mvc web application compatible with native
I am creating a web application in ASP.net/VB.NET and I have an issue with
I'm creating web site in asp.net web forms. I added validation to fields in
I'm creating REST service using ASP.NET Web API. How can I return 401 status
I am creating web page using asp.net. Is it possible to remove/hide the browsers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.