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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:44:33+00:00 2026-05-24T05:44:33+00:00

I have a page where user’s can "Ask a Question" against a product. The

  • 0

I have a page where user’s can "Ask a Question" against a product.

The route is:

context.MapRoute(
                "Q&A - Ask - by Product",
                "{someProductUri}/questions/ask",
                new { controller = "Questions", action = "Ask" }
            );

Which matches:

/car/questions/ask

/phone/questions/ask

Here’s the action:

public class QuestionsController : Controller
{
    public ViewResult Ask(string someProductUri)
    {
      // ...
    }
}

Now, the problem is, i also need to allow the user to select the product on the page itself, e.g with no product pre-chosen in the URI.

Because this controller is in an area, this "default URL" will be like this:

/myarea/questions/ask

So what’s happening is, when i get to the action, "someProductUri" is set to "myarea", causing all sorts of grief.

I want to re-use the same action/view for both sets of URL’s, but i don’t want the route value to be set to "myarea" when it’s the default URL.

Hope that makes sense – any ideas?

Do i need a seperate route? Can i add a route constraint so that the "someProductUri" can’t be "myarea", so that it doesn’t match the route and falls back to the default?

  • 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-24T05:44:34+00:00Added an answer on May 24, 2026 at 5:44 am

    I already have too many routes, so i didn’t want to add another just for this edge case.

    So i ended up using a route constraint:

    public class NotEqualToAreaName : IRouteConstraint
    {
       public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
       {
          return String.Compare(values[parameterName].ToString(), route.DataTokens["area"].ToString(), true) != 0;
       }    
    }
    

    Pretty simple, and generic – so i can re-use it anytime i come across this type of edge case.

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

Sidebar

Related Questions

I have a page where a user can insert some order about some product.
I have a page where a user can import data to the site. either
I have a page where the user can dynamically add file upload boxes. Adding
I have a page where the user can edit various content using buttons and
I have a page where a user can upload a file along with some
I have a page upon which a user can choose up to many different
We have a page of search results which the user can hit in several
If I have a page whose url alias is /api/user/create, how can I name
I have a page where the user can drag and drop objects and save
I have a page where the user can select three different appointment days using

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.