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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:09:38+00:00 2026-05-28T19:09:38+00:00

I suspect I’m doing this wrong. For various reasons, my app forces the user

  • 0

I suspect I’m doing this wrong.

For various reasons, my app forces the user to make some choices right after login. In order to ensure that they enter the necessary data, I override the OnActionExecuting method in a base controller class to intercept any attempt at executing an action before this data has been entered, and redirect the user to the necessary page. I preserve the url of the action they were attempting to execute with the following code:

url = Url.RouteUrl("Default", filterContext.RouteData.Values);

(filterContext is an ActionExecutingContext object, and a parameter of OnActionExecuting.)

The problem I’m having is that, if the action was associated with a controller in an area, the url I get doesn’t reflect the area.

I understand from other posts that I can get the area name from the DataTokens collection of RouteData. But I’m uncertain of the best way to pass it. I suppose I could retrieve it and use the RouteValueDictionary.Add method to add it to RouteData.Values (assuming Values is not read-only at that point; I don’t know), but that feels a bit … odd, like somehow the point is being missed.

Is this really the way this is supposed to be done? Is there something wrong elsewhere, that Area is absent from my RouteData.Values?

  • 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-28T19:09:39+00:00Added an answer on May 28, 2026 at 7:09 pm

    I would just take it out of the data tokens in the filter and add it to route values. You can do it with RouteValues.Add:

    if (filterContext.RouteData.DataTokens.ContainsKey("area"))
        filterContext.RouteData.Values.Add("area", 
            filterContext.RouteData.DataTokens["area"]);
    

    The areas feature was added in MVC2, and I imagine this is a side effect of it not being in MVC1. However, as long as your RouteValues contains an “area” key, UrlHelper.RouteUrl should generate the correct URL for the area.

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

Sidebar

Related Questions

I hope/suspect this is easy, so I will ask here and make a fool
I suspect this applies to general ASP.Net too but I am not sure. If
One day I suspect I'll have to learn hadoop and transfer all this data
I suspect there's no perfect solution to this problem so least worst solution are
I suspect there's probably an easy answer to this I'm just not seeing, but
I suspect that RegSetValueEx is thread safe, but would like some confirmation from the
I suspect I am doing something dumb here but I am getting seg faults
I suspect this isn't possible as the anonymous inner class is private. Can I
suspect I'm trying to be too clever for my own good with this one!
I suspect the answer to this is No, based purely on the concept of

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.