Ambient form data in ASP.NET MVC -


i came across problem ambient form data, i've tried isolate following example.

view model:

public class viewmodel {     public int value { get; set; } } 

controller:

public class testcontroller {     public viewresult test1()     {         return(view(new viewmodel {value = 1}));     }      [httppost]     public viewresult test2(viewmodel vm)     {         vm.value = 2;         return(view(vm));     } } 

test 1 view:

@model viewmodel @using(html.beginform("test2", "test")) {     @html.textboxfor(m => m.value)     <button type="submit">send</button> } 

test 2 view:

@model viewmodel @model.value @html.textboxfor(m => m.value) 

submitting form in view 1 gives the, @ least me, surprising result in view 2: enter image description here

seems posted value gets used in textboxfor(). knows what's going on here , how avoid it?


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -