c# - Prevent use of MVC's HiddenFor function -
i have problem documented here , here , here , especially here where, in asp.net mvc4 view, html helper function @html.hiddenfor(m => m.id) use "wrong" data , cause data corruption.
this massive problem, , accepted "solution" aware of , design around it. think poor solution. (incidentally, use instead: <input type="hidden" value="@model.id" />)
every few months, or colleague forget , use html helper, , hell breaks loose before track down problem... once again.
how can eliminate use of function, avoid mistakes in future?
- it's not our code, cannot mark [obsolete]
- can override htmlhelper, that's lot of work eliminate 1 function
- can write unit test pick out code view? (and fail test if call detected)
- other ideas?
this not "problem", it's way it's supposed work. , it's not hiddenfor it, every helper it. it's way mvc designed work. fact don't seem understand how mvc works real problem.
this part of modelstate subsystem, , wise know how works. yes, it's not intuitive, it's far better know how things work pretend don't exist, because you'll end bitten in other ways other helpers.
but, if choose otherwise, suggest configuring stylecop deal issue
Comments
Post a Comment