卡西尼号错误:“此类型的页面无法提供” [英] Cassini Error: "This type of page is not served"

查看:345
本文介绍了卡西尼号错误:“此类型的页面无法提供”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Cassini中的Server类在我自己的应用程序中包括一个基本的Web服务器。我刚刚开始玩弄它以熟悉服务器的工作方式,并设置了一个简单的应用程序,如下所示:

I'm trying to use the Server class from Cassini to include a basic web server in my own application. I just started playing around with it to get familiar with the way the server works and I setup a simple app that is as follows:

    static void Main(string[] args)
    {
        Server server = new Server(80, "/", @"C:\Projects\");
        server.Start();
        Console.ReadLine();
        server.Stop();
    }

它可以让我浏览目录,但是如果我尝试单击文件,例如C#源文件(* .cs),它会出现以下错误:

It lets me browse through the directories, however if I try to click on a file, a C# source file (*.cs) for example, it gives the following error:


/应用程序中的服务器错误。

Server Error in '/' Application.

此类型的页面无法提供。

This type of page is not served.

说明:您拥有的页面类型
由于已明确禁止
,因此未满足请求的请求。
扩展名'.cs'可能不正确。

请查看下面的URL,并确保
拼写正确。

Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cs' may be incorrect.
Please review the URL below and make sure that it is spelled correctly.

我尝试在Cassini库中搜索该错误文本,但未找到任何内容。

I tried searching for that error text in the Cassini libraries, but didn't find anything.

此错误在哪里?来自(哪里?如何使它提供任何文件?
我知道这本来是要做asp.net和HTML的,但是我希望它也可以像普通服务器一样处理任何文件。

Where is this error coming from? How can I make it serve up any file? I know it's meant to do asp.net and HTML, but I want it to also server up any file like a normal server would.

推荐答案

.cs 文件和许多源代码类型被阻止呈现,因为它们由ASP.NET的禁止文件处理程序处理。

.cs files and many source code types are prevented from rendering because they are handled by ASP.NET's forbidden file handler.

最初是在主web.config中的以下设置中的以下位置配置的: c:\windows\microsoft.net\v2.0.50727\CONFIG\ web.config

This is initially configured in the following setting in the master web.config in c:\windows\microsoft.net\v2.0.50727\CONFIG\web.config:

< httpHandlers> 部分中查找请参阅以下设置:

Look for in the <httpHandlers> section, you see settings like:

<add path="*.cs" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/>

通常,这是一个好主意,因为它可以防止随意浏览可能包含敏感数据的源代码,例如

Generally this is a good idea because it prevents casual browsing of your source code which may contain sensitive data such as connection strings.

您应该可以通过以下操作在应用的本地web.config中删除此限制:

You should be able to remove this restriction in your app's local web.config by doing:

<configuration>
   <system.web>
      <httpHandlers>
         <remove verb="*" path="*.cs"/>
      </httpHandlers>
   </system.web>
</configuration>

我可能不建议在面向Web的生产环境中这样做。

I probably wouldn't recommend doing this on a web facing production environment.

这篇关于卡西尼号错误:“此类型的页面无法提供”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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