servicestackasp.net-mvc-5.2servicestack-razor

Servicestack Razor transforms sections into a nameless method (and throws errors)


I got the razor view engine working in my mvc application. first it threw an error the viewpage should inherit from the mvc.WebPageBase. I made my own viewpage that inherits from mvc.WebViewPage. (So not the servicestack razor ViewPage!)

I had it working (I Included the buildProvider in the web.config and added the apphost razor plugin).

But now when i build a simple page: enter image description here

I Get the following compiled code, with the error: Compiler Error Message: CS1026: ) expected

enter image description here

Am i doing something wrong, do i need to inject a certain method name for sections or something?


Solution

  • From your question it's not clear if you're using MVC or ServiceStack.Razor you can't use both in the same Web App as if you use MVC it hijacks Razor page handling.

    If you're using ServiceStack.Razor you need to inherit from ServiceStack's ViewPage<TModel>.

    If you're using MVC then you can't use ServiceStack.Razor which shouldn't be installed. See this post for inheriting a Custom MVC Razor View. Also you can try using the @inherits keyword to have your View Page inherit from a custom class, e.g:

    @inherits Trancon.NextGen.Core.Web.Razor.DefaultRazorPage<ViewModelType>