允许浏览器点击.cshtml文件并显示内容 [英] Allow browser to hit a .cshtml file and display the content

查看:423
本文介绍了允许浏览器点击.cshtml文件并显示内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个非常奇怪的请求,但总而言之,开发人员使用了错误的URL,该URL现在已打印在材料上.该网址是一个.cshtml文件,显然不允许通过IIS对其进行攻击.

I know this is a very odd request but to cut a long story short a developer have the wrong URL that has now been printed on material. The url was a .cshtml file which obviously is not allowed to be hit through IIS.

我需要允许此特定的cshtml或所有这些cshtml在浏览器中呈现为纯html.

I need to allow this particular cshtml or all of them to be rendered as plain html in the browser.

我们将不胜感激.

推荐答案

这可能不是最好的解决方案,但这是我所知道的.

This might not NOT the best solution, but it is the one I know of the top of my head.

转到您的Global.asax文件.从那里开始或按如下方式创建Application_AcquireRequestState函数:

Go to your Global.asax file. From there go inside of or create the Application_AcquireRequestState function as so:

void Application_AcquireRequestState(object sender, EventArgs e) { }

在上面的函数中检查路径是否与您的.cshtml文件匹配.如果是这样,请对常规的aspx页执行Server.Transfer.

Inside the above function check to see if the path matches your .cshtml file. If so, do Server.Transfer to a regular aspx page.

您可能还需要进入IIS设置并启用cshtml.

You might also have to go into IIS settings and enable cshtml to be served.

这篇关于允许浏览器点击.cshtml文件并显示内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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