Turning off the WebFormViewEngine when using razor?

后端 未结 2 1501
渐次进展
渐次进展 2021-01-31 14:22

I downloaded Glimpse this morning to try it out and noticed this when I click on the views tab:

\"Glimpse

相关标签:
2条回答
  • 2021-01-31 15:02

    It is perfectly OK to remove the web forms view engine if you are not using it. You can do it like:

    public class Global : HttpApplication
    {
        public void Application_Start()
        {
            // Clears all previously registered view engines.
            ViewEngines.Engines.Clear();
    
            // Registers our Razor C# specific view engine.
            // This can also be registered using dependency injection through the new IDependencyResolver interface.
            ViewEngines.Engines.Add(new RazorViewEngine());
        }
    }
    

    The above method calls go in your global.asax file.

    source of code

    0 讨论(0)
  • 2021-01-31 15:19

    An alternative would be to remove only the view engine you want to remove:

        var webformVE = ViewEngines.Engines.OfType<WebFormViewEngine>().FirstOrDefault();
        ViewEngines.Engines.Remove(webformVE);
    
    0 讨论(0)
提交回复
热议问题