locked
Integrate MVC project and WEB API RRS feed

  • Question

  • User-1548796982 posted

    Hello. Good time
    I have a solution and inside it is a Mvc project and a web api project.
    For the customer, I will create two sites in iis. One for the main site(Mvc) and one for the web api.

    I want to know if I can, not create a new web api project? No problem?
    If the number of customers is high and I forget to update the website for the web api, then the problem is created. For this, I want to see the WEB API included in the main project to avoid this problem?

    thank you

    Thursday, February 28, 2019 3:42 PM

Answers

  • User475983607 posted

    Yes, MVC and Web API can be hosted in the same applcation.  The standard Visual Studio new project template allows you to create a MVC/Web API project.  Simply create a new project and select both MVC and API and use it as a template.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 28, 2019 4:40 PM

All replies

  • User475983607 posted

    Yes, MVC and Web API can be hosted in the same applcation.  The standard Visual Studio new project template allows you to create a MVC/Web API project.  Simply create a new project and select both MVC and API and use it as a template.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 28, 2019 4:40 PM
  • User-1548796982 posted

    Yes, MVC and Web API can be hosted in the same applcation.  The standard Visual Studio new project template allows you to create a MVC/Web API project.  Simply create a new project and select both MVC and API and use it as a template.

    Thanks for your reply

    Does integration of projects can cause security or other issues?

    Thursday, February 28, 2019 5:14 PM
  • User753101303 posted

    Hi,

    As always it depends on your exact situation. It's a bit unclear if this web api project is only consumed by your MVC site or if it also available to other users for direct consumption as well ?

    If this is a "private" API site it makes sense to handle it together with the only site that is consuming this API (not sure how you handled authentication until then).

    If this is "public" API site it makes sense to handle this separetely so that for example 3rd party are still able to use your API while your main MVC site is down for maintenance or whatever...

    Thursday, February 28, 2019 5:31 PM
  • User475983607 posted

    tadbirgaran

    Does integration of projects can cause security or other issues?

    Depends on your security requirements and general architecture requirements which are unknown at this time.  

    Perhaps give it a try using a test project as suggested above.  Then you can test if the configuration fits your security requirements.

    Thursday, February 28, 2019 5:42 PM
  • User-1548796982 posted

    Hi,

    As always it depends on your exact situation. It's a bit unclear if this web api project is only consumed by your MVC site or if it also available to other users for direct consumption as well ?

    If this is a "private" API site it makes sense to handle it together with the only site that is consuming this API (not sure how you handled authentication until then).

    If this is "public" API site it makes sense to handle this separetely so that for example 3rd party are still able to use your API while your main MVC site is down for maintenance or whatever...

    I use these web api only for communication with other software and mobile applications

    Friday, March 1, 2019 6:15 AM