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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:47:36+00:00 2026-05-29T23:47:36+00:00

How do you get the object parameters, which action method was called with at

  • 0

How do you get the object parameters, which action method was called with at run-time, to accomplish something to the effect of the following

public ActionResult Index(Int32? x, Int32? y, DateTime? z, NumberStyles n) {
this.RouteData.Values["x"] = x
this.RouteData.Values["y"] = y
this.RouteData.Values["z"] = z
this.RouteData.Values["n"] = n
return View();
}

It seems like it should be a possible to the names and values of each parameter without this kind of tedious code.

Sometimes you can get the parameters which the action method was called with, by looking in RouteData, but this isn’t always the case, particularly if the action method was invoked with an ajax request, the parameters may not show up in the RouteData, and instead show up in the Request Params.

What I’m looking for, is a generic way to get each parameter that is defined in the action method signature at run-time, and gets the parameter’s actual object, run-time value, not just a string. Further more, it should work no matter how the action method was invoked, whether it may be the result of ChildActionExtensions.Action or an ajax callback.

RouteData and Request Params don’t seem to have what I’m looking for.

  • 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-29T23:47:37+00:00Added an answer on May 29, 2026 at 11:47 pm

    Your code sample is setting values back into the RouteData collection. Are you trying to pass parameters to your view using the RouteData collection? That’s not what it exists for, you might consider using ViewBag instead.

    Or, create a POCO which contains all your properties and let the data binder do all the work (so use @model YourType in your view and pass a single argument to your view. The default model binder will map the individual argument values for you).

    As far as the input value collections are concerned, there’s a good reason why the value is not to be found consistently in the collections you’ve mentioned.

    Perhaps the trick here is to clarify what’s going on prior to your action being invoked. The arguments to your action method can come from more than one source. For example, it may come from:

    1. The URL Path
    2. The URL query string (eg: in a GET, the parameters after the question mark ?)
    3. POSTed form data
    4. Explicit arguments from another action

    In your code sample above, the RouteData collection will only contain the value of “x” if your route has a matching parameter name.

    For example: “{controller}/{action}/{x}“. (this is a custom route pulling “x” from the path)

    Failing that, the values will be resolved using the default model binder and will be pulled from either the query string parameters or POST data as the case may be.

    The route value will take precedence. So if the above custom route was applied, the following URL:

    http://www.example.com/Something/Index/1?x=2
    

    would invoke your action with x=1. The 1 would then be found in the RouteData as pulled from the URL path and the x=2 found in the Request.QueryString would be ignored.

    If you are concerned with how x got its value, then you must take into account all of the above so you know where to look. There is also the question of which route is applied to the request, but that’s another topic altogether.

    All the input came across the wire as text.. it was the model binder that examined your action signature and converted to the types you specified (wherever that is possible).

    So, I don’t think what you are asking for exists even conceptually in this setting.

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

Sidebar

Related Questions

Can I get an object's name in run time (like getting an object's type
iam trying to get all object's xpath's from loaded page via selenium something similar
I have controller action which returns JsonResult and is consumed by jquery ajax get
If I have an Action like this: public ActionResult DoStuff(List<string> stuff) { ... ViewData[stuff]
I have a controller method in ASP.NET MVC that looks like this: public ActionResult
I have the following code which creates a dynamic object that is assigned to
Is it possible to access the request object inside an struts2 action's execute() method?
Possible Duplicate: What are the reasons why Map.get(Object key) is not (fully) generic According
How to get class object of a generic interface? For example, Boolean.class, Date.class. But
I want to get an object from the database if it already exists (based

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.