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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:05:55+00:00 2026-05-30T08:05:55+00:00

My question is regarding Page Routing in an ASP.net (VB) Web Forms website. I

  • 0

My question is regarding Page Routing in an ASP.net (VB) Web Forms website.

I need to route to 2 .aspx pages in multiple ways e.g.

routes.MapPageRoute("SEO", "{Title}/{Id}", "~/PageA.aspx")
routes.MapPageRoute("Catalogue", "Issue{IssueNumber}-{PageNumber}", "~/PageA.aspx")

but I need to implement some logic involving database queries (LINQ to SQL) on both routes e.g.

Route 1) Check a bit field, if false then physical file = PageA.aspx, true then PageB.aspx

Route 2) Lookup IssueNumber and PageNumber, retrieve PageId and add to RouteData, set physical file = PageA.aspx

I think the best way of doing this, is to implement an IRouteHandler class but I’ve not been able to determine:

  • Where to write the database queries in such class
  • How to set the physical file in the class
  • Where/how to add a new value to the route data i.e. PageId
  • Where to check that Id and Number fields are actually integers (constraints?)

I can’t find any useful VB.net documentation, any suggestions?

If not I’m going to have to resort to an intermediate .aspx page i.e. Transfer.aspx and then do the database queries and then store return values in session variables and then do a Server.Transfer(PageA.aspx), but this seems like an old-fashioned and inelegant way of doing it. Please help!

  • 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-30T08:05:57+00:00Added an answer on May 30, 2026 at 8:05 am

    Instead of writing your own IRouteHandler I’d suggest implementing your Route class. Override GetRouteData and setup the RouteData object that you return according to your needs.

    Where to write the database queries in such class

    As mentioned above, GetRouteData is the place you are looking for.

    How to set the physical file in the class

    On the RouteData object you return, set RouteHandler to a new PageRouteHandler instance. You can pass the physical path to PageRouteHandler’s constructor.

    Where/how to add a new value to the route data i.e. PageId

    Use the Values property of the RouteData object.

    Where to check that Id and Number fields are actually integers (constraints?)

    This should be done with route constraints. The sixth parameter to MapPageRoute for example is a RouteValueDictionary with contraints. To simple check that a parameter is an integer, use a regular expression, like so:

    routes.MapPageRoute("RouteName", _
      "product/{id}", "~/Products.aspx", _
      True, New RouteValueDictionary(), _
      New RouteValueDictionary() From { {"id", "\d+"} })
    

    See the “\d+” at the end? This is the regular expression that the id parameter needs to match.

    If you need more complex constraints you can do that as well, see e.g. http://stephenwalther.com/blog/archive/2008/08/07/asp-net-mvc-tip-30-create-custom-route-constraints.aspx

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

Sidebar

Related Questions

I am going through a weird problem right now regarding routing in ASP.NET WebForms.
I asked a question regarding how to display aspx and cs code on page,
I know the question regarding PHP web page scrapers has been asked time and
I am new to ASP.NET MVC and I have a question regarding viewing entity
Following on from this question , regarding accessing a PDF on a web page
I have one question regarding using JQuery UI tab control in the asp.net mvc
I have a question regarding the application state in asp.net. As i know, data
Following my question regarding a .NET YAML Library ... as there doesn't seem to
I have a question regarding a custom validator in my page. The custom validator
So I have a question regarding the best practice for a PHP page inserting

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.