Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

asp.net mvc - Publish WebAPI and MVC projects to same Azure Web Site?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Go to Azure portal and create an AzureWebsite -

enter image description here

Then setup an additional application in the settings as follows -

enter image description here

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

enter image description here

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

enter image description here

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

enter image description here

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...