5

I have run Two Applications in different ports.

One is : http://localhost:12345/

and another one is : http://localhost:50949/

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

How can i do it?

tereško
  • 58,060
  • 25
  • 98
  • 150
  • 3
    And what page do you expect to see if you open up http://localhost? This won't work at the same time, the first application that uses the port wins. – Rob May 06 '14 at 06:47
  • 1
    http://stackoverflow.com/questions/14911222/run-multiple-web-applications-in-one-visual-studio-development-server – Nagaraj S May 06 '14 at 06:48
  • @NagarajS , There have only one answer, I also saw that answer, But i can't get that answer 100% correct? –  May 06 '14 at 06:49
  • @user256103 yeah you are correct +1 – Nagaraj S May 06 '14 at 06:49
  • @Robert , Then How can i solve the cors issue, `bcs some peoples explained the cookies are does not send if you used different domain`. So i want to run my both application in same domain in visual studio locally. How can i do it dude? –  May 06 '14 at 06:52
  • Ok, the domain you talk about is "localhost" in this case, so only the port number changes. If you want to know where you can set the port number of your development webserver, then you should change your title accordingly, as it is a bit misleading. BTW: You can set the port number in your project properties on the tab page "web". – Rob May 06 '14 at 07:03

2 Answers2

8

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 (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:

  1. MyNamespace.Web on http://mysite/
  2. MyNamespace.Web.Api on http://mysite/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.

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

snow_FFFFFF
  • 3,235
  • 17
  • 29
5

If you configure Visual Studio to use IIS you can configure both websites under a different Virtual Directory, which will allow you to run them side-by-side. It does require you to have your routing setup correctly to understand the difference between ApplicationRoot and WebRoot, and that you're using the HTML Helpers objects everywhere to setup your routs in links.

You can also configure virtual directories in IIS express if you want to, but I suspect you'll need to dive into the XML to make it work.

Community
  • 1
  • 1
jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • 2
    FYI: I always use IIS for developing. One virtual directory per project. For debugging I connect to the process instead of pressing F5. This makes it faster to test my application without having to start from the home page every time and I also don't have to wait for the debugger to connect - unless I choose to. This behaviour has an added benefit; I learn to write logs in a way that makes error tracing possible. This is a invaluable in production. – LosManos May 06 '14 at 07:10
  • Then you'll probably also love ReAttach: http://visualstudiogallery.msdn.microsoft.com/8cccc206-b9de-42ef-8f5a-160ad0f017ae – jessehouwing May 06 '14 at 07:16
  • I most certainly will. Before VS2012(?) there was support for macros and it was easy to [write one for connecting to IIS](http://www.selfelected.com/attach-to-a-process-even-faster/). On a side note: there are forces to [get macros back to VS](http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2650757-bring-back-macros). – LosManos May 06 '14 at 07:27