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 8445331
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:37:51+00:00 2026-06-10T09:37:51+00:00

I am having problems with asp 4.0 routing. i have methods in Global.cs void

  • 0

I am having problems with asp 4.0 routing.

i have methods in Global.cs

void RegisterRoutes(RouteCollection routes)
{  
    routes.MapPageRoute("cats","Categories/{ct}/{catname}","~/catwise.aspx");  
} 

and

protected void Application_Start(object sender, EventArgs e)
{  
    RegisterRoutes(RouteTable.Routes);  
}

and on my master page

<a href="Categories/<%# Eval("Category_Id")%>/<%# Eval("Category_Name")%>"> 

this is working perfectly in first routing like Categories/1/Apple but now after first routing all the links are double fro routed page like Categories/1/Apple/Categories/2/Banana.

The links are climbing on each other so the page shows Resource not found
i tried setting Base but it made the matters worse.
I am not using any custom handlers

how should i solve this problem?/why is it not working properly?

tried using / before url like <a href="/Categories/<%# Eval("Category_Id")%>/<%# Eval("Category_Name")%>"> but it said resource not found so added / in routes.MapPageRoute("cats","/Categories/{ct}/{catname}","~/catwise.aspx");
but it threw compile time error saying url cannot contan / or ~ or ?.

  • 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-10T09:37:52+00:00Added an answer on June 10, 2026 at 9:37 am

    This is not a Routing issue. The problem is with the link. I don’t know if the is a better way to generate links in Web Pages but a quick fix would be to simply add a /:

    <a href="/Categories/<%# Eval("Category_Id")%>/<%# Eval("Category_Name")%>">
    

    EDIT:

    When you are in the home page http://mysite/ and the browser see a “relative” link like Categories/1/Apple it adds that to the current path so the outcome is http://mysite/Categories/1/Apple. Because your link is relative to the page, the next time you hit the link the browser adds that again and you have http://mysite/Categories/1/Apple/Categories/1/Apple. The quick fix I proposed is about changing your relative link to absolute by adding a leading /.

    The whole issue has nothing to do with asp.net and its routing. Its about how the browser treats relative links. I think there are more proper ways to generate links (when using routing), like:

    <asp:HyperLink ID="HyperLink1" runat="server" 
        NavigateUrl="<%$RouteUrl:ct=1,catname=Apples,routename=cats%>">
        Link Text
    </asp:HyperLink>
    

    In the data binding scenario you can try:

    <asp:HyperLink ID="HyperLinkClient" runat="server"  
        NavigateUrl='<%# GetRouteUrl("cats", new {ct = Eval("Category_Id"), catname = Eval("Category_Name")}) %>'> 
         Link Text 
    </asp:HyperLink>
    

    See also here

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

Sidebar

Related Questions

I have an ASP TextBox with TextMode set to MultiLine. I'm having problems with
I have an ASP.NET MVC2 application in development and I am having problems rendering
Im doing a page in .asp and im having this problem ... I have
i am having problems with an asp.net c# site whereby i am setting a
I'm having problems with my ASP.NET web forms system. It worked on our test
I'm having some problems publishing an asp.net mvc3 application. When deployed, the application fails
I am actually migrating websites to ASP.NET 4.0, having problems with the new rendering
MicrosoftMvcJQueryValidation.js is used by ASP.NET MVC 2 for client side validation. Having problems with
I am having some trouble when I use ASP .Net 4's URL Routing feature
I'm having problems using JQuery inside an ASP.Net User Control I've created a sample

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.