开发者

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

开发者 https://www.devze.com 2023-03-29 14:56 出处:网络
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?

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 decl开发者_如何转开发aration 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


You can use the Bind attribute:

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

精彩评论

暂无评论...
验证码 换一张
取 消