简体   繁体   中英

Disable request parameters binding when calling child action

I render a view for an action with this url: "/search?a=1&b=2"

The correspoding action is:

public ActionResult Search (int? a, int? b)

Inside it's view I need to call this child action:

public ActionResult Count (int? a, int? b)

But with only with "a" parameters set. So I call:

Html.RenderAction ("Count", new { a = 5 })

But my child action called as Count (5, 2) because there is a "b" in query string and it's been automatically binded.

Is there a way ( edit : without need to specify "b" parameter as empty strings because I have method with a lot of parameters) to overcome this and dissalow model binder to use query string (or any other) sources of parameter values for a specific action call?

Html.RenderAction("Count", new { a = 5, b = "" })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM