卡西尼号错误:“不提供此类页面”

发布于 2024-07-12 02:31:19 字数 704 浏览 7 评论 0原文

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

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

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

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

不提供此类页面。

描述:您拥有的页面类型 请求未得到满足,因为它已 被明确禁止。 这 扩展名“.cs”可能不正确。
请查看下面的 URL 并进行 确保拼写正确。

我尝试在卡西尼号库中搜索该错误文本,但没有找到任何内容。

这个错误从何而来? 我怎样才能让它提供任何文件? 我知道它的目的是执行 asp.net 和 HTML,但我希望它也能像普通服务器一样提供任何文件。

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();
    }

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.

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.

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小耗子 2024-07-19 02:31:19

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

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

: httpHandlers> 部分,您会看到如下设置:

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

一般来说,这是一个好主意,因为它可以防止随意浏览可能包含敏感数据(例如连接字符串)的源代码。

您应该能够通过执行以下操作在应用程序的本地 web.config 中删除此限制:

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

我可能不建议在面向 Web 的生产环境中执行此操作。

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

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

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.

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>

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

你怎么敢 2024-07-19 02:31:19

下载并安装 MS ASP.Net 网页对我有用。

http://www.microsoft.com/download/en/details.aspx ?id=15979

S.

Downloading and installing the MS ASP.Net Web Pages worked for me.

http://www.microsoft.com/download/en/details.aspx?id=15979

S.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文