M80
M80

Reputation: 994

Run multiple web applications in one Visual Studio development server?

I have 2 ASP.Net MVC web application, ParentSite and ChidSite. ParentSite has a page which will open a pop-up window which will navigate to child site, when childpage is done it notifies the parent page. However I'm getting a cross domain error as

Parent is = http://localhost:49000/Home
Child is = http://localhost:50000/Home

Is there a way in Visual Studio where I can run both the web application under one port in Visual Studio development server ( NOT ON LOCAL IIS SERVER ).

If we use the same-port in the project, Visual Studio automatcally chooses a dynamic port if there is already DEV server running on it.

Thanks for the help.

Upvotes: 2

Views: 5657

Answers (1)

MisterJames
MisterJames

Reputation: 3326

No, you can't host two applications under the same port/application space. Think of things like web.config, routing (as mentioned in the comments), security, etc. Those are all part of that space.

You could try to solve the cross-domain errors, but this isn't straightforward and isn't cross-browser friendly (yet). I hope that changes.

You have a couple of options:

  • Expose the bits you need to on ChildSite with WebAPI and consume it from ParentSite from the controller. You can do this with simple HTTP gets, and return the JSON to the popup (which would now live on the ParentSite). The client is no longer accessing the 3rd party site.
  • Use areas or portable areas to incorporate the child project into the ParentSite

To add areas simply right-click on your MVC project in Solution Explorer and select Add -> Area.

Cheers.

Upvotes: 3

Related Questions