使用Cassini取代IIS做为Web服务器(这一过程中必要注意的事情)

本文介绍了解决Cassini服务器在远程访问时出现403错误的方法,通过修改Request.cs文件中的代码限制及调整web.config配置来实现远程服务的支持。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在远程访问 Cassini中的应用程序会遇到403错误

出现这种情况是因为,Cassini中Request.cs文件中第93行中以一段代码,这一段代码就限制了Cassini只能用于本地,将这一段代码注释掉之后,就可以Cassini服务于远程机器了
       // Limit to local requests only
         if (!_conn.IsLocal) {
              _conn.WriteErrorAndClose(403);
              return;
           }
 Take a look in Request.cs about line 93, in method Process().
In my copy (from the Cassini in a Service sample), there is an if statement limiting requests to being local, and returning 403 if not.  Comment out this if statement and it should serve remotely as well as localhost.

Also, look at Host.cs about line 199, in method Start(), where the _socket.Bind(...) call is.
Be sure it is bound to IPAddress.Any to serve more than localhost.

I would expect something similar in the .NET 2.0 version of the source.

-Jesse Chisholm

另外使用Cassini服务于WebService还可能出现这种情况,"测试窗体只能用于来自本地计算机的请求"
出现这种情况,的解决办法是
The test form is only available for requests from the local machine.

在web.config中加入如下配置节内容
<webServices>
 <protocols>
    <add name="HttpSoap"/>
    <add name="HttpPost"/>
    <add name="HttpGet"/>
    <add name="Documentation"/>
 </protocols>
</webServices>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值