[英]How can I configure Cassini web server to accept requests to different hosts?
See duplicate: Customizing the cassini webserver 请参阅重复: 自定义cassini Web服务器
I have a web service hosted using Cassini web server. 我有一个使用Cassini Web服务器托管的Web服务。 It works fine if I reference it by localhost, but when I use my machine's name (even using the browser locally), I get: 如果我通过localhost引用它,它工作正常,但当我使用我的机器名称(甚至在本地使用浏览器)时,我得到:
Server Error in '/' Application.
HTTP Error 403 - Forbidden.
Version Information: Cassini Web Server 1.0.40305.0
How can I configure it to accept all requests? 如何配置它以接受所有请求?
Cassini is specifically build to reject any outside connections. Cassini专门用于拒绝任何外部连接。 You could rebuild from sourcecode if you want it to accept outside connections. 如果您希望它接受外部连接,您可以从源代码重建。
Edit: 编辑:
In reply to the below comment on what to edit in the sourcecode, you'd probably want to change the following in Server.cs
on line 88: 在回复以下关于源代码中要编辑的内容的注释时,您可能希望在第88行的Server.cs
更改以下内容:
_socket = CreateSocketBindAndListen(AddressFamily.InterNetwork,
IPAddress.Loopback, _port);
Into something like this: 进入这样的事情:
_socket = CreateSocketBindAndListen(AddressFamily.InterNetwork,
IPAddress.Any, _port);
This will bind the listening socket to all available IP addresses on the system instead of only to the localhost address (127.0.0.1). 这会将侦听套接字绑定到系统上的所有可用IP地址,而不是仅绑定到本地主机地址(127.0.0.1)。
To update this answer, IIS Express is a new alternative that allows this. 为了更新此答案,IIS Express是一种允许这样做的新选择。
http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx http://weblogs.asp.net/scottgu/archive/2010/06/28/introducing-iis-express.aspx
为了避免其他人不得不走得更远,如果您需要一个轻量级的Web服务器用于生产 , 那么不建议使用IIS-Express(单独使用)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.