I have defined an extension method in app_code like below.
public static class Extensions
{
public static string Hi(this object obj)
{
return
C# only allows you to call extension methods qualified by an object instance.
If you have an extension method that extends your type, you can't call it "directly"; you need to write this.ExtensionMethod()
.
The only way to do what you're asking for is to make a class which inherits WebPage
(or WebViewPage
for MVC views) and change your Razor page to inherit that class (using the @inherits
directive)