Problem using Razor after migrating MVC 2.0 to MVC

2019-04-10 11:32发布

I migrated a MVC 2.0 site to MVC 3.0, using that : Migrating MVC 2.0 -> 3.0

Using ASPX as View Engine works great now...

But I tried to create a Razor view and got that error:

The view 'TestView' or its master was not found. The following locations were searched:

    ~/TestView.aspx
    ~/TestView.ascx
    ~/Views/Color/TestView.aspx
    ~/Views/Color/TestView.ascx
    ~/Views/Shared/TestView.aspx
    ~/Views/Shared/TestView.ascx

How can I enable razor on that?

I´m using Visual Studio 2010... Creating a brand new MVC 3 Web Application enables Razor fine!

Thanks

2条回答
Fickle 薄情
2楼-- · 2019-04-10 12:03

Please review

In Solution Explorer, delete the reference to System.Web.Mvc (which points to the version 2 DLL). Then add a reference to System.Web.Mvc (v3.0.0.0). Also add a reference to System.WebPages.dll and System.Web.Helpers.dll.

查看更多
混吃等死
3楼-- · 2019-04-10 12:11

Try adding ViewEngines.Engines.Add(new RazorViewEngine()); to your global.asax file

查看更多
登录 后发表回答