User907863
User907863

Reputation: 417

Asp.net MVC3 access internal class from razor View

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.

Upvotes: 4

Views: 1350

Answers (1)

stepdo
stepdo

Reputation: 11

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!

Upvotes: 1

Related Questions