Publish WebAPI and MVC projects to same Azure Web Site?

帅比萌擦擦* 提交于 2019-11-27 04:15:56

问题


I have two seperate projects in Visual Studio - one with a WebAPI and one with a MVC Web Site...

Can I publish both of these to the same Azure Web Site, so that requests to: - /api/products/ => gives JSON from the WebAPI - /products/ => gives HTML from the MVC web site


回答1:


Go to Azure portal and create an AzureWebsite -

Then setup an additional application in the settings as follows -

Now create two projects in the Visual studio solution -> 1) MVC and 2) WebApi

Download publishsettings file of above created azure website. Import the publishsettings file to the Visual studio MVC project publish as shown below -

And for WebApi project, import the same publish settings, but create a new path as website/webapi.

Publish both the projects.

Now navigate to http://{yoursite}.azurewebsites.net for the MVC site. And navigate to http://{yoursite}.azurewebsites.net/webapi/api for your WebApi.



来源:https://stackoverflow.com/questions/23428799/publish-webapi-and-mvc-projects-to-same-azure-web-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!