使用剃刀时关闭 WebFormViewEngine? [英] Turning off the WebFormViewEngine when using razor?

查看:15
本文介绍了使用剃刀时关闭 WebFormViewEngine?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天早上下载了

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

It checks all of the loaded view engines. I found where the RazorViewEngine is specified in web.config, but I couldn't find where the WebFormViewEngine was. Since I know my project will never have an web form view in it,

  1. Is it ok/safe to turn off WebFormViewEngine?
  2. How can I turn off WebFormViewEngine?

解决方案

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

这篇关于使用剃刀时关闭 WebFormViewEngine?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆