我可以使用web.config文件中的视图文件夹覆盖一个MVC面积的自定义错误/ [英] Can I override the custom errors of an mvc area using the web.config in the view folder/

查看:90
本文介绍了我可以使用web.config文件中的视图文件夹覆盖一个MVC面积的自定义错误/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个区域,我叫/管理员

I have an area in my Mvc solution called /Admin

在/管理/ views文件夹有一个标准的web.config文件。

Within the /Admin/Views folder there is a standard web.config file.

我已经列入本配置对System.Web下提交customerErrors元素:

I have included in this config file a customerErrors element under the system.web:

<customErrors mode="On" defaultRedirect="~/admin/oops" >  
  <error statusCode="404" redirect="~/admin/pagenotfound"/>
</customErrors>

从一个在我的根web.config不同。

Which differs from the one in my root web.config.

我的期望是,这会给我的错误是如何处理在管理领域的具体控制。

My expectation was that this would give me specific control of how errors are dealt with in the admin area.

这是行不通的。

我是疯了服用药丸或我应该能够用更具体的一个在该地区的web.config覆盖默认的web.config设置?

Am I taking crazy pills or should I be able to override the default web.config settings with a more specific one in the area's web.config?

推荐答案

其实这里是写在MVC方面的文章。

Actually here is an article written about areas in mvc.

在ASP.NET MVC

根据这篇文章,我们不能覆盖这些设置。

According to this article, we cannot override the settings..

在Web.Config中的文件夹视图
  网页也被称为视图是在视图文件夹中。在MVC中的观点不直接URLS暴露于外部。所有视图的请求应该去控制器它将呈现利用URL输入的精确视图。视图是正常的asp.net网页,使他们能够访问的URL。要限制的意见直接访问,我们使用的web.config文件中的意见文件夹中。 web.config中有一个默认的处理程序映射到块的所有页面具有扩展ASPX。

Web.Config in Views folder Pages also called views are available in the views folder. In MVC views are not directly exposed to outside by URLS. All the view requests should go to the controller and it will render the exact view using the inputs from URL. Views are normal asp.net web pages, so they can be accessible a URL. To restrict direct accessing of views, we use web.config file in views folder. The web.config has a default handler mapping to blocks all the pages which has extension ASPX.

在Web.Config中夹区
  同样,对于意见,有一个服务于同一目的,每个区域一个web.config文件。这是限制的ASPX文件的访问。如果我们不想在区级,限制他们,我们可以删除此web.config文件。

Web.Config in Area folder Similarly for views, there is a web.config file for each area serving the same purpose. This is to restrict access of ASPX files. If we don't want to restrict them at area Level, we can delete this web.Config file.

在Web.Config中的应用设置
  有很多web.config文件中;我们可以在特定的区域web.config文件领域应用程序设置?答案是否定的,我们不能或有或覆盖AppSettings的配置。所有的应用程序设置,应在根文件夹的web.config文件中定义

Application settings in Web.Config There are many web.config files; can we have application settings of areas in area specific web.config file? The answer is No, we cannot or have or override the appsettings configurations. All the application settings should be defined in the web.config of the root folder

这篇关于我可以使用web.config文件中的视图文件夹覆盖一个MVC面积的自定义错误/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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