什么是Web.Config文件在MVC项目的意见,做文件夹 [英] What does the Web.Config file do in the views folder of a MVC project

查看:178
本文介绍了什么是Web.Config文件在MVC项目的意见,做文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,我的部署应用和进行故障诊断时,我整个的Web.Config 文件中的的观看次数文件夹中。在试图缩小的来源,我的问题的可能性,我试图找出〜Web.Config`文件的目的,但真的不能找到多少信息。

I'm having some problems with deploying my application and while troubleshooting, I came across the Web.Config file in the Views folder. In an attempt to narrow down the possibilities of sources to my problem, I tried to find out the purpose of that ~Web.Config` file but can't really find much information.

所以基本上我的问题是:

So basically my questions are:


    一个MVC项目的
  1. 什么是的Web.config 文件中的做浏览文件夹?

  2. 需要它?

  1. What does the Web.config file do in the Views folder of a MVC project?
  2. Is it required?

在Asp.Net web表单,我认为,一个文件夹中使用一个单独的web.config文件,该文件夹已被设置为IIS中的虚拟文件夹。这是MVC的情况下(即是否查看文件夹需要被配置为虚拟文件夹)?

In Asp.Net webforms, I believe that to use a separate web.config file in a folder, that folder has to be set as a virtual folder in IIS. Is this the case in MVC (i.e. does the Views folder need to be configured as a virtual folder)?

推荐答案

没有,你不需要配置,因为这些额外的web.config文件的虚拟文件夹。

No, you do not need to configure a virtual folder because of this extra web.config file.

在web.config文件存在于浏览文件夹比控制器其他任何方式prevent访问您的看法。在MVC设计模式,控制器都应该路由请求和返回渲染视图到调用客户端。

The web.config file exists in the Views folders to prevent access to your views by any means other than your controller. In the MVC design pattern, controllers are supposed to route requests and return a rendered view to the calling client.

在换句话说,你在www.mydomain.com/MySuperController/AwesomeAction1/SweetPage.aspx视图应该的的直接访问。

In other words, your view at www.mydomain.com/MySuperController/AwesomeAction1/SweetPage.aspx should not be directly accessible.

如果你偷看的web.config文件,它实际上注册 HttpNotFoundHandler 来的所有路径和动词:

If you peek at the web.config file it actually registers the HttpNotFoundHandler to all paths and verbs:

<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>

,或在IIS 7它看起来像

Or, in IIS 7 it might look like

<add name="BlockViewHandler" path="*.aspx" verb="*" 
    preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>

这篇关于什么是Web.Config文件在MVC项目的意见,做文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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