简体   繁体   中英

Web Services in ASP.NET MVC 4 Application

I've a web site developed using MVC 4 ASP.net application. I'm new to .net platform & I want to add web service which would return me operating system name of users device based on certain input.

Assuming I've logic to capture OS information using inputted data, how do I go forward in building this web service?

Do I need to have a complete separate solution file which will have a web service or in existing MVC 4 asp.net application itself, should I create a new project which would be of type "WCF Service Application"? Again I don't know much about WCF service either, if I use it, how would the URL be accessible, etc?

Can anyone give me some insights?

Note: I've also a separate REST web service which is a completely separate solution with separate projects but deployed on same IIS.

Thanks in Advance!

You don't need to create a WebAPI project just for what you described (i'm assuming one or a few end points).

Simply use MVC controllers that return JSON for example, this way you deal with a single framework.

Reasons to move to Web API is if you need support for CORS, need content negotiation for results etc. From what you are describing it's completely fine to stay with MVC.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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