Brian Mains
Brian Mains

Reputation: 50728

Calling Method In View in Razor Web Pages

I have a custom view base class that inherits from WebPage. I want in Razor to call a method in this class, but I keep getting errors saying "the method 'X' does not exist in the current context." Since I'm essentially using the method like any of the other methods (RenderPage, for example), why is this not working? What am I missing here?

I do have my view registered because I am using other methods of it in the @functions block...

 <system.web.webPages.razor>
    <pages pageBaseType="Nucleo.Web.Views.BaseViewWebPage" />
  </system.web.webPages.razor>

Upvotes: 3

Views: 535

Answers (2)

Brian Mains
Brian Mains

Reputation: 50728

I don't know why, but the DLL never refreshed, and that is why I was getting the error. When I deleted it and rebuilt, it works fine.

Upvotes: 1

David Ebbo
David Ebbo

Reputation: 43203

Based on the error, it looks like you are trying to call RenderViewPage(), but there is no such method on WebPage. I assume you want to call RenderPage() instead, which should work.

Upvotes: 0

Related Questions