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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:14:12+00:00 2026-05-25T06:14:12+00:00

if possible then please provide me code for implementing url routing. suppose i have

  • 0

if possible then please provide me code for implementing url routing. suppose i have two url in my page like

first one


http://www.mysite.com/101/category.aspx

so i want that when user click on the above url then request should goes like

http://www.mysite.com/category.aspx?id=101 but

http://www.mysite.com/101/category.aspx this url should show in the addressba.

when any user will directly type url like http://www.mysite.com/category.aspx?id=101 then no routing will happen rather above url should process and

http://www.mysite.com/category.aspx?id=101 this url should show in the addressbar.

second one


http://www.mysite.com/audi/product.aspx

so i want that when user click on the above url then request should goes like

http://www.mysite.com/product.aspx?cat=audi but

http://www.mysite.com/audi/product.aspx this url should show in the addressbar.

when any user will directly type url like http://www.mysite.com/product.aspx?cat=audi then no routing will happen rather above url should process and

http://www.mysite.com/product.aspx?cat=audi this url should show in the addressbar.

i have never work with url routing….so please guide me in terms of coding. 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-05-25T06:14:12+00:00Added an answer on May 25, 2026 at 6:14 am

    In ASP.NET using the IIS7 rewrite module you would use something like this:

    <rewrite>
      <rules>
        <rule name="Rewrite to category.aspx">
          <match url="^([0-9]+)/category.aspx" />
          <action type="Rewrite" url="category.aspx?id={R:1}" />
        </rule>
        <rule name="Rewrite to product.aspx">
          <match url="^(.*)/product.aspx" />
          <action type="Rewrite" url="product.aspx?cat={R:1}" />
        </rule>
      </rules>
    </rewrite>
    

    Updated as realised you can’t pass routing variables as querystring with MapPageRoute as I originally showed. In fact things get tricky if you want to do this. There’s 2 options I can think of.

    Option 1)

    Use the following route.

    routes.MapPageRoute(
       "category",
       "{category}/category.aspx",
       "category.aspx"
    );
    

    Then use the following code in your category.aspx instead of querystring to extract the category value.

    ControllerContext.RouteData.Values["category"];
    

    Option 2)

    This involves creating custom handler to rewrite the RouteData into the querystring when the path is rewritten.

    public class PageRouteWithQueryStringHandler : PageRouteHandler
    {
        public RouteWithQueryHandler(string virtualPath, bool checkPhysicalUrlAccess)
            : base(virtualPath, checkPhysicalUrlAccess)
        {
        }
    
        public RouteWithQueryHandler(string virtualPath)
            :base(virtualPath)
        {
        }
    
        public override IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            var request = requestContext.HttpContext.Request;
            var query  = HttpUtility.ParseQueryString(request.Url.Query);
            foreach (var keyPair in requestContext.RouteData.Values)
            {
                query[HttpUtility.UrlEncode(keyPair.Key)] = HttpUtility.UrlEncode(
                                                   Convert.ToString(keyPair.Value));
            }
            var qs = string.Join("&", query);
            requestContext.HttpContext.RewritePath(
                                 requestContext.HttpContext.Request.Path, null, qs);
            return base.GetHttpHandler(requestContext);
        }
    }
    

    This can be registered as follows.

    routes.Add("category", new Route("{category}/category.aspx",     
               new PageRouteWithQueryStringHandler ("~/category.aspx", true)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a texture, is it then possible to generate a normal-map for
Is it possible to use request.setAttribute on a JSP page and then on HTML
Is it possible to send 100 Continue HTTP status code, and then later some
how can we insert symbol of copyright in application programatically?? if possible then please
I have a code like <ul id=uploadedfiles> <li> A_001 </li> <li> B_001 </li> </ul>
I have two sites running which share a membership provider. One of them is
I know it's possible to match a word and then reverse the matches using
Is it possible to sort a MembershipUserCollection by IsApproved and then Comment without modifying
Is it possible to generate a file in javascript and then prompt the user
Is it possible to load an html document using ajax and then perform a

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.