mat-mcloughlin
mat-mcloughlin

Reputation: 6702

asp mvc action needs to accept parameter with full stop in the name`

Not sure if this is possible but I need my action to bind to a query string parameter with a full stop in the name. Is this possible?

For example my query string is

http://foo.com?foo.bar=test

so is there anything I can put in my method declaration so I can pick it up?

public JsonResult TestAction(string foo.bar)

(I know this wont work)

I know I can get the value from the Request object but I'd rather not do that.

Thanks in advance

Upvotes: 0

Views: 644

Answers (1)

John Oxley
John Oxley

Reputation: 14990

You can use the Bind attribute:

public JsonResult TestAction([Bind(Prefix="foo.bar")]string foobar)

Upvotes: 4

Related Questions