is Bind[(exclude ..)] removed from ASP Core?

半城伤御伤魂 提交于 2020-01-25 00:23:13

问题


I am trying to exclude some properties from binding when getting values from View I am using at the action level : Bind exclude as the following :

I need this property to sent to the view (as readonly) but not allowing the user to update the value or even hacker try to inject value .... the question:is exclude no longer available in ASP MVC Core ? is there any other way ? again I know I can exclude the Property at Model level (using neverbind) but I want only send the value to the view , but not receive them back !


回答1:


There are some discussion in : https://github.com/aspnet/AspNetCore/issues/4857 :

Yup. I wanted a strict binder where you had to specify everything, but apparently this was too mean. Of course really everything should be view model based.

How would you feel about throwing if someone bound to a class used in a dbcontext?

So currently you may need to use include for security concern .



来源:https://stackoverflow.com/questions/55665609/is-bindexclude-removed-from-asp-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!