如何忽略特定视图文件夹或ASP.NET MVC 4 sepecific CSHTML文件路径 [英] How to Ignore route for a specific View folder or a sepecific cshtml file in ASP.NET MVC 4

查看:175
本文介绍了如何忽略特定视图文件夹或ASP.NET MVC 4 sepecific CSHTML文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在浏览文件夹浏览特定网页时忽略路由,我不成功地试图通过使用:

I want to ignore the routing when browse a specific page in the Views folder, I unsuccessfully attempted that by use :

        routes.RouteExistingFiles = false;
    routes.IgnoreRoute("Views/NoMove/specificPage.cshtml");

但上面没有工作,因为互联网浏览器问我要下载的文件,它不会打开/过程中,它的页面!

But above didn't work, because the Internet browser ask me to download the file and it doesn't open/process it the page!

有什么问题请和如何解决它!

What is the problem please, and How to fix it!

推荐答案

您将需要在你的web.config添加一个条目。

You'll need to add an entry in your web.config.

检查的appSettings 部分

添加这个(或更新)

<add key="webpages:Enabled" value="true" />

该条目可能是已经存在,所以只需更新从假值设置为true。

The entry is probably there already, so just update the value from false to true.

他们是2 web.config文件中虽然..一个在您的应用程序的根目录下,另一个在Views文件夹..你可能需要添加/更新这两个条目。

They are 2 web.config files though .. one in the root of your app and another in the views folder .. you may need to add/update the entry on both.

默认值()prevents *。CSHTML * .vbhtml 直接从浏览器正在访问的文件。

The default value (false) prevents *.cshtml and *.vbhtml files from being accessed directly from the browser.

这篇关于如何忽略特定视图文件夹或ASP.NET MVC 4 sepecific CSHTML文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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