0
votes

Looks like I'm missing something here and I can't figure it out what it is. I'm creating a MVC3 VB.NET application using VS2010 VB Web Project templates. I have removed all the (.aspx) views and created .VBHTML Razor view - named Index.vbhtml under the Home folder. The HomeContoller has the action Index. When I run the app I get the below error.

The view 'Index' or its master was not found. The following locations were searched: ~/Views/Home/Index.aspx

~/Views/Home/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx ~/Views/Home/Index.cshtml ~/Views/Shared/Index.cshtml

Obviously the view engine can't locate the .vbhtml view. Can anyone please tell me how to enable this? The same setup works with .cshtml files.

3

3 Answers

1
votes

Did you register Razor as a ViewEngine?

protected void Application_Start()
{
    // ...
    ViewEngines.Engines.Add(new RazorViewEngine(("vb")));
}
0
votes

Since you removed all of the .aspx I am guessing that this application was not originally a Razor application? Did you add the reference to Razor in the web config?

<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
0
votes

Sorry it was my mistake. I haven't had the latest MVC3 installed and was screwing up everything. Thanks a lot. ViewEngines.Engines.Add(new RazorViewEngine(("vb"))); pointed me to the right direction. The version I was referencing didn't had the RazorViewEngine