问题
I have converted a site over entirely to Razor and want it to ignore any residual .aspx files. These have caused problems by
- not being deleted from the production server and
- being recreated by NuGet packages. In this case, the ASPX takes precedence and any customization to the equivalent CSHTML file are not in play.
I would like to tell the entire site to stop processing ASPX or ASCX pages and only use Razor views.
回答1:
Add following to Global.asax.cs
protected void Application_Start()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
}
By default a WebFormViewEngine
is included BEFORE RazorViewEngine
.
来源:https://stackoverflow.com/questions/8434015/get-mvc-razor-favor-cshtml-over-aspx