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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:18:31+00:00 2026-06-14T14:18:31+00:00

Having this routes.MapRoute( ShowPage, default.aspx/{page}/{pagetype}, new { controller = Info, action = PageASPX, page

  • 0

Having this

routes.MapRoute(
    "ShowPage",
    "default.aspx/{page}/{pagetype}",
    new {
        controller = "Info",
        action = "PageASPX",
        page = "emptypage",
        pagetype = "emptypagetype"
    }
);

To catch default.aspx?page=order
(I need to generate a permanet redirect fom the old site to my new MVC site)

The route is matched as I can see in route debugger, but I don’t get any values in the route

Key          Value
page         emptypage 
pagetype     emptypagetype 
controller   Info 
action       PageASPX 

What’s wrong??

  • 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-14T14:18:33+00:00Added an answer on June 14, 2026 at 2:18 pm

    MVC route definitions have URL segments. Your route looks like this:

    default.aspx/{page}/{pagetype}
    

    this means that requests like default.aspx/order should populate page value during route resolution because it’s provided as a URL segment. This doesn’t mean that page won’t get populated later on when model binding occurs and your controller action gets invoked.

    If your controller action signature seems similar to this:

    public ActionResult PageASPX(string page, string pagetype)
    {
        ...
    }
    

    Those two parameters may still get populated even when you’d provide them as query variables and not URL segments. The only requirement is that routing doesn’t provide default values for missing segment values (or they’re set as optional). Default MVC model binder will then populate page action parameter with actual query variable value.

    So the main thing is that you should change your routing definition (see last section of my answer).

    Requests that should work

    In order for your routing to recognise page and pagetype URL segment variables your requests should look like this:

    default.aspx/somepage
    default.aspx/somepage/sometype
    

    Provided that your routing doesn’t define defaults for page and pagetype then your controller actions will get page and pagetype parameters populated with correct values when your requests look like:

    default.aspx/somepage
    default.aspx/somepage/sometype
    default.aspx?page=somepage
    default.aspx?pagetype=sometype
    default.aspx?page=somepage&pagetype=sometype
    

    Mixing route values and query string variables

    As my tests show Asp.net MVC doesn’t provide route value overriding when it has a value (either provided in the URL itself as segment or as route defaults). In your case if you’d request this URL:

    default.aspx/routepage?page=querypage
    

    your action method would see page parameter to have value of routepage. Always.

    The more important aspect of this is that when you provide default value in route definition itself, you won’t be able to set it as a query string at all even when you omit it from the URL. To avoid this issue, you have two choices:

    1. set page and pagetype as UrlParameter.Optional which will allow you to override their values with query string variables when URL won’t have them – this means that you can always use only URL segments or query strings, but not both, because URL segments prevails

    2. have different names for URL segment variables and query string variables – the downside is that you’d need to have your action with double parameters which is undesired:

      public ActionResult PageASPX(string routePage, string routeType, string queryPage, string queryType)
      {
          string page = routePage ?? queryPage ?? string.Empty;
          string type = routeType ?? queryType ?? string.Emtpy;
          ...
      }
      

    Best solution

    Change your routing so you have separate routing definition for variables provided as URL segments and another for variables provided as query string variables. Then wire these routes to the same controller action as long as all variables (in segments and query string) share the same names:

    route.MapRoute(
        "InSegmentsBoth",
        "default.aspx/{page}/{pagetype}",
        new { controller = "Info", action = "PageASPX" }
    );
    route.MapRoute(
        "InSegmentsPage",
        "default.aspx/{page}",
        new { controller = Info"", action = "PageASPX" }
    );
    route.MapRoute(
        "InQueryString",
        "default.aspx",
        new { controller = "Info", action = "PageASPX" }
    );
    

    If your requests provide both values (segments and query variables) as in

    default.aspx/segmentpage?page=querypage
    

    then segment values have precedence so action parameter page will have value of segmentpage for this request.

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

Sidebar

Related Questions

I have these routes defined: routes.MapRoute(CategoryList_CountryLanguage, Categories/{id}/{urlCategoryName}/{country}/{language}, new { controller = Categories, action =
Given the following routes: routes.MapRoute(name: CityHomePage1, url: {city}-{state}, defaults: new { controller = Home,
I'm trying to learn MVC and having a rough start. routes.MapRoute( Test, Test/{stringInput}, new
I'm having problems rerouting my pages from website.com/controller/action to website.com/admin/controller/action. I tried adding this
Having this code: using (BinaryWriter writer = new BinaryWriter(File.Open(ProjectPath, FileMode.Create))) { //save something here
Having this code... var b = new ReadOnlyCollection<int>(new[] { 2, 4, 2, 2 });
Having this line Cursor c = db.rawQuery(PRAGMA table_info(?), new String[] {tableName}); and getting this:
I have started to write my map routes like this: routes.MapRoute(Image/{fileID}/{width}/{height}/{fileName}, (ContentController c) =>
I'm new to Forms Authentication and am having difficulty with this problem: I have
iam having controller like below which is not registered in routes table public class

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.