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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:09:48+00:00 2026-06-16T01:09:48+00:00

Lets say I have this sql server table : id Name Band ——————– 1

  • 0

Lets say I have this sql server table :

id   Name      Band
--------------------
1    John      Beatles
2    Paul      Beatles
3    George    Beatles
4    Ringo     Beatles 
5    Jim       Doors

I want to have a person details page like :

http://localhost/Music/Beatles/Paul

and I want to treat is as :

http://localhost/Details.aspx?id=2

And so- I’m writing this code to register a simple route :

void Application_Start(object sender, EventArgs e)
{
    RouteTable.Routes.MapPageRoute("MyRoute", "Music/{Band}/{Name}", "~/Details.aspx");
}

But I don’t understand :

When Asp.net get http://localhost/Music/Beatles/Paul , how does he know it knows that Paul’s value is 2 ?

Are you telling me that each time asp.net encounters Paul he should go to DB and scan a pre-defined unique column (Name in this case) and get it’s column ID value?

Or Should I inject Paul’s value into the url like SO doing :

 http://stackoverflow.com/questions/13938994/jquery-conditional-validation-based-on-select-text 
                                       ^
                                       |
---------------------------------------

which will be in my case :

http://localhost/Music/Beatles/2/Paul

  • 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-16T01:09:50+00:00Added an answer on June 16, 2026 at 1:09 am

    Asp.net does not intrinsicly know that Paul’s ID is 2.

    You would have to write this logic somewhere yourself. You could write your own RouteHandler and do the routing yourself (which would do the db call to determine the proper ID).

    Personally, I would just let the aspx page handle the information itself and not assume it is given an actual ID.

    Here’s a code sample of a custom route handler (taken from Friendly URLs for ASP.NET)

    public class CustomRouteHandler : IRouteHandler
    {
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            string virtualPath = "~/path/to/page.aspx";
    
            int id;
    
            // this would obviously be some sort of database call
            if (requestContext.RouteData.Values["Name"] == "Paul") 
            {
                id = 2;
            }
            else
            {
                id = 8675309;
            }
    
            string newPath = string.Format(
                "{0}?id={1}",
                virtualPath,
                id
            );
    
    
            HttpContext.Current.RewritePath(newPath);
    
            return BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page)) as IHttpHandler;
        }
    }
    

    And to register the route

    RouteTable.Routes.Add("MyCustomRoute", new Route("Music/{Band}/{Name}", new CustomRouteHandler());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a SQL Server 2000 table, any name will do, it's
Lets say I have a table called Projects in my SQL server. My dbml
Lets say I have a table in a sql server 2000 database called TransactionType:
I'm trying to format a table from XML. Lets say I have this line
I have a view in SQL Server, lets say MY_VIEW. When I execute the
SQL Server 2005+. I have a table with the following schema/data: Name Slots Date
I have SQL server 2008 R2. I want to get column name and table
For simplicity's sake, let's say I have a SQL Server CE table called Widgets
Lets say have this immutable record type: public class Record { public Record(int x,
Lets say I have this code: <?php class hello { var $greeting = hello;

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.