在Visual Studio中的同一端口上运行两个应用程序 [英] Run two Application on Same Port in Visual Studio

查看:165
本文介绍了在Visual Studio中的同一端口上运行两个应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在不同的端口中运行了两个应用程序.

I have run Two Applications in different ports.

一个是: http://localhost:12345/

另一个是: http://localhost:50949/

现在我遇到了cors域问题,所以我想在vs 2012中的相同端口号上运行这些应用程序

Now I got a cors domain issue, So I want to run those applications on same port number in vs 2012

我该怎么办?

推荐答案

我要添加另一个带有其他选项的答案.使用成熟的IIS具有一些优点,但是并不是每个人都安装了IIS,甚至没有安装它的选项.默认情况下,Visual Studio将为每个项目分配端口,并在IIS Express中创建它们.但是,您可以在项目属性中轻松覆盖它.

I'm adding another answer with another option. Using full-blown IIS has some advantages, but not everyone has it installed or even has the option to install it. Visual Studio, by default, will assign ports to each project and create them in IIS Express. However, you can easily override it in the project properties.

作为一个例子,我可能有两个看起来像这样的项目:

As an example, I might have two project that look like this:

  1. MyNamespace.Web (当前正在监听端口12345)
  2. MyNamespace.Web.Api (当前正在监听端口54321)
  1. MyNamespace.Web (currently listening on port 12345)
  2. MyNamespace.Web.Api (currentlly listening on port 54321)

当我部署它们时,我将它们运行在不同的虚拟目录中,如下所示:

When I deploy these, I'll run them in different virtual directories like this:

    http://mysite/ 上的
  1. MyNamespace.Web
  2. MyNamespace.Web.Api http://mysite/api

要在带有IIS Express的Visual Studio中模拟这一点,我可以转到 MyNamespace.Web.Api 的项目属性,并将Project Url(在服务器"下,在"Web"选项卡上)更改为 http://localhost:12345/api/并单击创建虚拟目录"按钮.

To mimic this in Visual Studio with IIS Express, I can go to the Project Properties of MyNamespace.Web.Api and change the Project Url (under Servers, on the Web tab) to http://localhost:12345/api/ and click the "Create Virtual Directory" button.

我的两个项目现在都在IIS Express上运行,使用相同的端口,但位于不同的虚拟目录中.

My two projects are now running on IIS Express, using the same port, but in different virtual directories.

这篇关于在Visual Studio中的同一端口上运行两个应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆