c# - How to route MVC so that I can post a form with a model.action parameter? -


hopefully easy 1 out there.

i trying post form mvc controller happens have "action" property on model.

unfortunately, model.action resolving controller action, not posted model's action property.

public class postmodel {     public string action { get; set; }     public string username { get; set; }     public string password { get; set; } }  public actionresult dosomething(string id, postmodel model) {   // id == 98f4   // model.username == "test"   // model.password == "test"   // model.action == "dosomething" not "test" expecting. } 

here post:

post -> http://localhost:7832/forms/dosomething/98f4?username=test&password=test&action=test 

please keep in mind have no control on form data being posted, cannot change model's action property. need able address problem on mvc server side.

how overwrite setting of action property in model acction of controller? need functionality 1 particular controller in project.

any suggestions?

ok figured out problem. use of fiddler2 hit controller action. when had action part of url, mvc replace controller action.

when made action part of request.body, , added "content-type: application/x-www-form-urlencoded" header, controller model had expected values.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -