简体   繁体   English

ASP.NET Web Api-目标URI和部署

[英]ASP.NET Web Api - Target URI and deployment

So I'm brand new to developing an API, I have an existing MVC website which is published on Azure, and I would like to create my API using the ASP.NET Web Api template in a new project. 因此,我是开发API的新手,我有一个现有的MVC网站,该网站已在Azure上发布,并且我想在新项目中使用ASP.NET Web Api模板创建我的API。

My question is in deployment. 我的问题是在部署中。 How can I deploy this API so that the target address is like: 如何部署此API,以便目标地址如下所示:

www.MyMVCWebsite.com/api/etc... www.MyMVCWebsite.com/api/etc ...

I don't want to modify my existing MVC site to contain the api as I've seen some posts mention that it is less secure, and all tutorials I've seen are for the web api template and I'm learning this from scratch. 我不想修改现有的MVC网站以包含api,因为我已经看到一些帖子提到它的安全性较差,并且我所看到的所有教程都是针对Web api模板的,我正在从头开始学习。

Within the publish to azure settings in visual studio it gives the option to publish to an existing site...would this achieve what I want or is there more to it? 在Visual Studio中的“发布到天蓝色”设置中,它提供了发布到现有站点的选项...这是否可以实现我想要的功能?

JK JK

You just need to configure the routes to what you want it to be. 您只需要将routes配置为您想要的routes即可。

routes.MapHttpRoute(
name: "API Default",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);

See Here 这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM