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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:15:53+00:00 2026-05-24T17:15:53+00:00

I’m using ASP.NET routing to map URLs to some arbitrary number of sections to

  • 0

I’m using ASP.NET routing to map URLs to some arbitrary number of sections to my site. They will all be handled by the same page, though I want to have different URLs. For example

http://site.com/blog for my blog section
http://site.com/mysection for mysection etc.

There can be any number of those sections, but they will all be handled by Lister.aspx.
I also have another page that handles the content, named ContentView.aspx which shows off content. My route is as follows: (cats is list of categories)

cats.ForEach(c =>
        {
            table.Add(new Route(c.ShortName, new PageRouteHandler("~/Lister.aspx?cat=" + c.ID), ));
            table.Add(new Route(c.ShortName + "/{id}", new PageRouteHandler("~/ContentView.aspx")));
            table.Add(new Route(c.ShortName + "/{id}/{title}", new PageRouteHandler("~/ContentView.aspx")));
        });

Let’s say I have a blog post with ID 123 and title hello:
A user can access it by http://site.com/blog/123/hello
They can also use just the ID http://site.com/blog/123
As you may guess, I want http://site.com/blog to point to the lister page instead of a content viewer, and I also need the category ID to distinguish which category (blog or mycategory or anything else that was created dynamically) I should display. I’m trying to pass the category ID to the querystring, the lister page is called, but with no query string. Why is this behavior, and how can I send my category ID to the lister page?

  • 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-05-24T17:15:55+00:00Added an answer on May 24, 2026 at 5:15 pm

    I would suggest creating your own RouteHandler that implements IRouteHandler which you could then pass a separate parameter to its constructor (the category ID).

    Then in the GetHttpHandler you could then pass that ID on to the Page using HttpContext.

    Something like:

    public class CategoryRouteHandler : IRouteHandler 
    {
       private string _virtualPath;
       private string _category;
    
       public CategoryRouteHandler(string virtualPath, string category)
       {
           _virtualPath = virtualPath;
           _category = category;
       }
    
       public IHttpHandler GetHttpHandler(RequestContext requestContext) 
       {
            var handler = BuildManager.CreateInstanceFromVirtualPath(
                _virtualPath, typeof(Page)) as IDefaultHttpHandler;
    
            HttpContext.Current.Items["Category"] = _category;
    
            return handler;
       }
    } 
    

    Then you can use:

    table.Add(new Route(c.ShortName, new CategoryRouteHandler("~/Lister.aspx", c.ID), ));
    

    And from the code of Lister you can access HttpContext.Current.Items["Category"]

    Edit: updated to fix the code, sorry I didn’t test it the first time.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am using Paperclip to handle profile photo uploads in my app. They upload
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT

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.