简体   繁体   English

在与ASP.Net应用程序相同的端口上启动.Net Web服务

[英]Starting .Net web service on the same port as the ASP.Net application

We have a simple Visual Studio solution containing 2 projects: 我们有一个包含2个项目的简单Visual Studio解决方案:

  • A.) Simple ASP.Net website A.)简单的ASP.Net网站
  • B.) RESTful web service hosted in another ASP.Net application B.)在另一个ASP.Net应用程序中托管的RESTful Web服务

We want to simply start the projects in Debug mode (F5) and have A consume data from B through Ajax. 我们想在调试模式(F5)中简单地启动项目,并让A从B到Ajax消耗数据。 We do not have the possibility to configure IIS on all development machines (because some of them are on the client's side). 我们没有可能在所有开发机器上配置IIS(因为其中一些是在客户端)。 The problem might be that JavaScript needs to be in the same domain as the URL it posts to. 问题可能是JavaScript需要与其发布的URL位于同一个域中。

Is there any way we can use Visual Studio 2010 Development Server to start both applications simultaneously in debug mode on the same port? 有没有什么办法可以使用Visual Studio 2010开发服务器在同一端口上以调试模式同时启动两个应用程序?

If this is not possible, what is the next best thing you can recommend? 如果这是不可能的,那么你可以推荐的下一个最好的东西是什么?

We solved this problem by installing IIS on the development workstation. 我们通过在开发工作站上安装IIS解决了这个问题。 In each Visual Studio project, on the Web property page, select Use Local IIS Web server. 在每个Visual Studio项目的Web属性页上,选择“使用本地IIS Web服务器”。 Do not check Use IIS Express. 不要选中使用IIS Express。 The Project URLs will be set to http:localhost/<projectname> (note: in the same domain). 项目URL将设置为http:localhost / <projectname>(注意:在同一个域中)。 You'll be prompted to Create a Virtual Directory for each. 系统将提示您为每个创建虚拟目录。 Each will be assigned to the default IIS app pool. 每个都将分配给默认的IIS应用程序池。 Open the Internet Information Services (IIS) Manager. 打开Internet信息服务(IIS)管理器。 Click Application Pools on the left pane. 单击左窗格中的“应用程序池”。 On the right pane add another integrated application pool. 在右侧窗格中添加另一个集成的应用程序池。 For one of the applications, open the Advanced Settings... In the properties view select the app pool you just created as the application pool. 对于其中一个应用程序,请打开“高级设置”...在属性视图中,选择刚刚创建的应用程序池作为应用程序池。 The applications should be debuggable in parallel because each Application Pool spawns a new operating system process to which a separate debugger can be attached. 应用程序应该可以并行调试,因为每个应用程序池都会产生一个新的操作系统进程,可以附加一个单独的调试器。

Yo won't be able to host different apps on the same port within a Cassini instance, there are tools that might be useful but I would leave Cassini host them on different ports which is its regular behavior. Yo将无法在Cassini实例中的同一端口上托管不同的应用程序,有些工具可能有用,但我会让Cassini将它们托管在不同的端口上,这是它的常规行为。

Options are (not tested): 选项(未测试):

UltiDev UltiDev

Cassini Extesion 卡西尼号Extesion

By the way, not sure if you know this, but to start both projects go to Set startup projects , there's an option on the Solution context menu. 顺便说一下,不知道你是否知道这一点,但要启动这两个项目,请转到设置启动项目解决方案上下文菜单上有一个选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM