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

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

问题描述

我今天早上下载掠影来尝试一下,注意到这一点,当我点击Views标签:

这将检查所有已加载的视图引擎。我发现,其中在web.config中指定了 RazorViewEngine ,但我无法找到 WebFormViewEngine 在哪里。因为我知道我的项目将永远不会有它的网页表单视图,


  1. 它是确定/安全关闭 WebFormViewEngine

  2. 如何关闭 WebFormViewEngine


解决方案

这是完全确定,如果你不使用它来删除Web表单视图引擎。你可以不喜欢它:

 公共类全球:一个HttpApplication
{
    公共无效的Application_Start()
    {
        //清除所有previously注册视图引擎。
        ViewEngines.Engines.Clear();        //注册我们的剃刀C#特定视图引擎。
        //这也可以通过新的IDependencyResolver接口使用依赖注入注册。
        ViewEngines.Engines.Add(新RazorViewEngine());
    }
}

以上方法调用去你的Global.asax文件。

code

来源

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天全站免登陆