c# - ASP.Net 4.5 error on compiling -
below code, when compiling getting 3 errors shown
any help appreciated.
using system; using system.collections.generic; using system.linq; using system.web; using system.web.modelbinding; using system.web.ui; namespace build01 { public static class modelbindingextensions { public static modelbindingexecutioncontext getmodelbindingexecutioncontext(this page page) { homecoming new modelbindingexecutioncontext { httpcontext = new httpcontextwrapper(httpcontext.current), modelstate = page.modelstate }; } } }
error 1 'system.web.modelbinding.modelbindingexecutioncontext' not contain constructor takes 0 arguments error 2 property or indexer 'httpcontext' cannot assigned -- read only error 3 property or indexer 'modelstate' cannot assigned -- read only
modelbindingexecutioncontext
not have constructor takes 0 arguments. but have 1 takes both httpcontext
, modelstatedictionary
, need pass constructor:
return new modelbindingexecutioncontext( new httpcontextwrapper(httpcontext.current), page.modelstate);
c# asp.net
No comments:
Post a Comment