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

  • Home
  • SEARCH
  • 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 6538753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:46:25+00:00 2026-05-25T10:46:25+00:00

I am using Martijn Bolands paging and I have an issue with GetVirtualPathForArea method.

  • 0

I am using Martijn Bolands paging and I have an issue with GetVirtualPathForArea method.

I have two pages: /Page1 and /Page2.

I’ve set a MapRoute for /Page1 and is accessed as /Page1Name

routes.MapRoute(
      "Page1 name", // Route name
       "Page1Name", // URL with parameters
       new { controller = "ContollerName", action = "ActionName" } // Parameter defaults
);

If I try to get the Vitrual Path from Page1Name page, it gives me the correct one.

But!! If I try to get the Virtual Path from page2, it gives me again the Page1Name.

I haven’t set any Route for Page2 and If do this, then in Page1 I will get the VirtualPath of Page2.

Call and Methods

The call is through an HtmlHelper as follows

public static HtmlString Pager(this HtmlHelper htmlHelper, int pageSize, int currentPage, int totalItemCount, string actionName, RouteValueDictionary valuesDictionary, string controllerName) {
        if (valuesDictionary == null) {
            valuesDictionary = new RouteValueDictionary();
        }
        if (actionName != null) {
            if (valuesDictionary.ContainsKey("action")) {
                throw new ArgumentException("The valuesDictionary already contains an action.", "actionName");
            }
            valuesDictionary.Add("action", actionName);
        }
        var pager = new Pager(htmlHelper.ViewContext, pageSize, currentPage, totalItemCount, valuesDictionary, null, controllerName);
        return pager.RenderHtml();
    }

This is from RenderHtml() method

It gets the viewContext from htmlHelper and this is the call to get the virtualPath

var pageLinkValueDictionary = new RouteValueDictionary(linkWithoutPageValuesDictionary) { { "page", pageNumber } };
var virtualPathForArea = RouteTable.Routes.GetVirtualPathForArea(viewContext.RequestContext, pageLinkValueDictionary);

Is it a known issue? Have I set something in a wrong way?

Thanks and I’ll appreciate any comment.

  • 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-25T10:46:26+00:00Added an answer on May 25, 2026 at 10:46 am

    Response from microsoft:

    The behavior you’re mentioning here is actually “by design”, if a route URL (such as your first route: FirstPage) has no parameters, no defaults, and no constraints, the call to RouteTable.Routes.GetVirtualPathForArea() will match this route (when it gets to it as it tries to match the route one by one in the order they are added).
    The general fix is to make one of those conditions false OR to use named routes.

    You can read more about this in a blog post by Phil Haack here: http://haacked.com/archive/2010/11/21/named-routes-to-the-rescue.aspx

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

Sidebar

Related Questions

I am using the pager provided by Martijn Boland to implementing paging in my
Using JDeveloper , I started developing a set of web pages for a project
I have a page that has two tabs created using jQuery, and I am
Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
We have a batch-based buildprocess and we are using MSBuild only for compiling our
We have an application that creates several threads using the pthread library. As we
I am using Martin Orth's ColdFusion API for Google Adwords. I have been able
Does the order in which I set properties using the object initializer syntax get
I have a filehandler class that moves an xdoument to cache using a lock.

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.