发布的WebAPI和MVC项目同Azure的网站? [英] Publish WebAPI and MVC projects to same Azure Web Site?

查看:246
本文介绍了发布的WebAPI和MVC项目同Azure的网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio中两个不同的项目 - 一个具有的WebAPI和一个具有MVC Web站点...

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

我可以公布这两个相同的Azure的网站,这样的请求:
- / API /产品/ =>给JSON从的WebAPI
- /产品/ =>从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的门户网站,并创建一个AzureWebsite -

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

上面创建蔚蓝网站下载publishsettings文件。导入publishsettings文件到Visual Studio MVC项目发布为如下 -

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

和对项目的WebAPI,导入相同的发布设置,而是创建一个新的路径,网站/的WebAPI

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

发布两个项目。

现在导航到http:// { yoursite } .azurewebsites.net的MVC站点。并导航到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的网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆