Asp.net MVC3 access internal class from razor View

浪子不回头ぞ 提交于 2020-12-05 12:25:09

问题


This is not a duplicated question. I've already searched on SO but I need a different thing.

Is today a way to access an internal class from Razor View, I know that the assembly must be visible and is it yet.

No properties nor methods declared in an "internal" class are accessible from Views by default. I need a way to override this.

Thanks.


回答1:


In most cases you can change the class from internal to public. You can use the InternalsVisibleTo when that isn't desirable.

In the case of .Designer.cs files that are auto-generated with resource (.resx) files, you can change the "Access Modifier" to "public" by opening the resx file in the "Designer" view:

If all else fails, you should be able to use reflection to get what you need. See the top answer here for details on that

Best of luck!



来源:https://stackoverflow.com/questions/11630919/asp-net-mvc3-access-internal-class-from-razor-view

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