Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use internal class on in inline asp code

Tags:

c#

asp.net

I try to use an internal class in an inline ASP code.

Ex : <%= MyClass.Method() %>

It's work fine with a public class, but I can't manage to use this with an internal class even with using assembly:InternalsVisibleTo

Is it possible to use an internal class or method in inline code ?

like image 333
SeyoS Avatar asked Nov 29 '25 10:11

SeyoS


1 Answers

Internal types or members are accessible only within files in the same assembly.

Because .aspx page is inherited from .aspx.cs code-behind class.

You can only get value by protected or public in .aspx.cs code-behind, otherwise you can't access the field or property.

InternalsVisibleToAttribute attribute only represent you can get the Internal class from another assembly, but the key point is .aspx will render a page and get value <%= MyClass.Method() %> from the code behind- class. there isn't any relationship about another assembly

like image 188
D-Shih Avatar answered Dec 02 '25 01:12

D-Shih



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!