简体   繁体   English

如何配置Cassini Web服务器以接受对不同主机的请求?

[英]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.

相关问题 如何强制我的Web服务接受其他前缀? - How can I force my web service to accept a different prefix? 如何在Cassini会话中检查数据? - How can I inspect data in a Cassini Session? 如何在不将其添加到GAC的情况下使Cassini网络托管框架正常工作? - How can I get Cassini web hosting framework to work without adding it to GAC? 代码使Cassini Web服务器崩溃 - Code crashing Cassini web server 如何以编程方式编辑Windows 7 / Server 2008中的hosts文件? - How can I programmatically edit the hosts file in Windows 7/Server 2008? 如何配置Visual Studio C#单元测试解决方案以接受不同的运行时配置? - How do I configure a Visual Studio C# unit test solution to accept different runtime configurations? 如何将ReSharper配置为接受[Required](来自PostSharp)等同于[NotNull](反之亦然)? - How can I configure ReSharper to accept [Required] (from PostSharp) as equivalent to [NotNull] (or vice versa)? 如何在Asp.Net Web Api中接受复合请求 - How to accept composite requests in Asp.Net Web Api 如何在web.config中为CustomBinding配置TransportSecurityBindingElement? - How can I configure a TransportSecurityBindingElement for a CustomBinding within a web.config? 我可以配置Swagger UI以使用Swashbuckle接受并清空数组吗? - Can I configure Swagger UI to accept and empty array using Swashbuckle?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM