问题描述
我在 Visual Studio 中有两个单独的项目 - 一个带有 WebAPI,一个带有 MVC 网站...
I have two seperate projects in Visual Studio - one with a WebAPI and one with a MVC Web Site...
我可以将这两个发布到同一个 Azure 网站,以便请求:-/api/products/=> 提供来自 WebAPI 的 JSON-/products/=> 提供来自 MVC 网站的 HTML
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
推荐答案
转到 Azure 门户并创建 Azure 网站 -
Go to Azure portal and create an AzureWebsite -
然后在设置中设置一个额外的应用程序如下 -
Then setup an additional application in the settings as follows -
现在在 Visual Studio 解决方案中创建两个项目 -> 1) MVC 和 2) WebApi
Now create two projects in the Visual studio solution -> 1) MVC and 2) WebApi
下载上面创建的 azure 网站的发布设置文件.将publishsettings文件导入Visual Studio MVC项目publish如下图-
Download publishsettings file of above created azure website. Import the publishsettings file to the Visual studio MVC project publish as shown below -
对于 WebApi 项目,导入相同的发布设置,但创建一个新路径为 website/webapi.
And for WebApi project, import the same publish settings, but create a new path as website/webapi.
发布这两个项目.
现在导航到 MVC 站点的 http://{yoursite}.azurewebsites.net.并导航到 http://{yoursite}.azurewebsites.net/webapi/api 以获取 WebApi.
Now navigate to http://{yoursite}.azurewebsites.net for the MVC site. And navigate to http://{yoursite}.azurewebsites.net/webapi/api for your WebApi.
这篇关于将 WebAPI 和 MVC 项目发布到同一个 Azure 网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!