开发者

How to locate MVC3 Razor (.VBHTML) View?

开发者 https://www.devze.com 2023-02-11 20:00 出处:网络
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 cr

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 fou开发者_如何学JAVAnd. 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.


Did you register Razor as a ViewEngine?

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


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" />


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

0

精彩评论

暂无评论...
验证码 换一张
取 消