2

In ASP.NET MVC 2 (yes, TWO, I'm using MONO for this), I would like to know if it is at all possible to bind multiple Request parameters into an Action method parameter.

Let me give an illustration.

I'm passing 2 parameters (using whatever method I like, GET, POST, etc.):

  • Name
  • Guid

Is there a way to bind those parameters to this:

public JsonResult MyMethod(NameClass identifier)

Instead of this:

public JsonResult MyMethod(string name, string guid)

Using this?

public class NameClass
{
    public string Guid { get; set; }
    public string Name { get; set; }
}
0

1 Answer 1

1

Absolutely. You simply have to name your fields using dot notation as if you were going to access the property from inside the method. This means that the Guid field is named identifier.Guid and the Name field identifier.Name. It is too bad that you can't take advantage of strongly-typed user controls however ;).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.