C # only allows calling extension methods defined by an instance of an object.
If you have an extension method that extends your type, you cannot call it "directly"; you need to write this.ExtensionMethod() .
The only way to do what you ask is to create a class that inherits WebPage (or WebViewPage for MVC views) and change the Razor page to inherit this class (using the @inherits directive)
source share