asp.net mvc 4 - MVC 4 is overwriting specific Action-Parameters -


mvc 4 present me strange behaviour @ moment.

imagine following code:

testcontroller.cs

public class testcontroller : controller {     public actionresult index(function function, string action)     {         return view();     }      public class function     {         public string action { get; set; }     } } 

it seems, when call url directly through browser (localhost:port/test), action-property gets automatically filled "index". if action named "mysuperduperactionwhichgetsinvokedquiteoften", methodname in property.

can explain mvc doing here? problem is, of course want fill stuff myself, example through ajax-query. if mvc filling in property itself, breaks behaviour.

i could, of course, rename property , working, still quite interesting what's going on.

edit

i understand second parameter, string action, get's filled method-name. why on earth mvc bind any property/parameter named same request-value of it?

it problem default model binder. "maps" request fields properties in class. there article of msdn describing how works situation code this:

action = request["action"] //where of course request["action"] equals name of action 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -