Can a Post method take parameters from the Query String?

YES is the answer (if you are in hurry to leave the site); and adding a keyword [FromUri] before model param in action method is the trick to do it.

How It Works:

If you have a model Foo:

public class Foo
public string Bar { get; set; }
public int Baz { get; set; }

And you want to bind this from the query string, then you must address the individual properties:


And annotate that the model must be bound from the query string:

public void Bar([FromUri]Foo foo)
  //your intelligent code goes here..


And if you want to send JSON into your action method and not a model, simply bind to a string instead of a model. In action method you can deserialize this string to a json model or key-value pair and then can do whatever you want with the JSON string inside your action method.

Say something : I accept all the "Humer&Critic"

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s