Iskander Raimbaev
Iskander Raimbaev

Reputation: 1362

How to run ASP.NET MVC and WebAPI projects in the same time?

I am developing a complex web-platform with n-tier architecture. There are two projects inside solution: PresentationLayer.WebSite and APILayer.Restful.

Local database stored in App_Data inside PresentationLayer.WebSite. I have no idea how to implement following actions : (currently I'm workind in debug mode).

  1. Set connection string from Restful project to Presentation Project. Should I use absolute path? They should use the same DB. Of course, in publish moment DB will be placed in some server,but what to do now?
  2. How can I run two projects in the same time? I know how to call one's project's controller from another, but how to run it togetgher? For example: in Chrome I call User\MyProfile?.... (Presentation) and in Firefox i call Api\User\GetUserById... (Rest).

Upvotes: 8

Views: 2779

Answers (2)

matiii
matiii

Reputation: 326

Connection string should link to one database. Just set direct path to one DB in both projects. In Visual Studio in Solution click propertis and in the Common Propertis tab you have Multiple startup projects and in the Action column you have to set right projects which should on the start.

Upvotes: 2

Kahbazi
Kahbazi

Reputation: 14995

Right click on your solution and select Properties. In the "Startup Project" select "Multiple startup projects" and set "Action" of your projects to "Start"

Upvotes: 17

Related Questions