哪个NuGet包在您的“视图"文件夹中创建了web.config? [英] Which NuGet package creates the web.config in your Views folder?

查看:59
本文介绍了哪个NuGet包在您的“视图"文件夹中创建了web.config?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目缺少Views文件夹中的web.config文件.这是我制作项目的步骤.

My project is missing the web.config file from the Views folder. Here are the steps I took to make the project.

  • 创建了一个空的MVC项目并安装了下面列出的软件包.
  • 创建了一个控制器和视图.通过右键单击操作名称并从菜单中选择添加视图..."来创建视图.
  • 尝试运行项目,但出现错误CS0103: The name 'ViewBag' does not exist in the current context

我收到此错误,因为Views文件夹中缺少web.config.由于web.config包含很多版本号,令牌等...,我的问题是:

I am getting this error because web.config is missing from my Views folder. Since the web.config contains a lot of version numbers, tokens, etc..., my question is:

  1. 为什么在安装软件包时未添加此内容?
  2. 软件包是否创建了可用于制作web.config文件的模板?
  1. Why wasn't this added when I installed the packages?
  2. Did the packages create a template I can use to make the web.config file?

我安装的软件包:

Antlr   3.4.1.9004
bootstrap   3.3.4
jQuery  1.9.1
Microsoft.AspNet.Mvc    5.2.3
Microsoft.AspNet.Razor  3.2.3
Microsoft.AspNet.Web.Optimi...  1.1.3
Microsoft.AspNet.WebPages   3.2.3
Microsoft.Web.Infrastructure    1.0.0.0
Modernizr   2.6.2
Newtonsoft.Json 5.0.4
Ninject 3.2.2.0
Ninject.MVC5    3.2.1.0
Ninject.Web.Common  3.2.0.0
Ninject.Web.Common.WebHost  3.2.0.0
WebActivatorEx  2
WebGrease   1.5.2

推荐答案

问题应该看起来像这样,如注释中所述,它是项目模板的一部分,而不是程序包

Should prob look like this, as said in the comments it's part of the project template and not a package

<?xml version="1.0"?>

<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>

  <system.webServer>
    <handlers>
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>
</configuration>

更新

以上是Views文件夹中的默认配置文件,使用Visual Studio 2013创建时,它将添加到新的Web项目中.它使用

The above is the default config file from the Views folder, it is added to a new Web Project when it's created using Visual Studio 2013. It uses

  • Microsoft.AspNet.Mvc 5.2.2
  • Microsoft.AspNet.Razor 3.2.2
  • Microsoft.AspNet.WebPages 3.2.2

这篇关于哪个NuGet包在您的“视图"文件夹中创建了web.config?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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