1

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!

8
  • 2
    It seems WCF is quietly going to die and WebAPI is going to take over. Do take a look at WebAPI, it's definitely a lot more easier than WCF. It's also quite powerful. You can have it in the same project or separate. Commented May 1, 2014 at 23:38
  • 4
    @Pathachiever11 - WCF isn't going anywhere. WebAPI only does a small subset of what WCF does. Commented May 1, 2014 at 23:41
  • Is Web API available in Visual Studio 2010? Also, how do I add this web api? Is it like creating new project within same MVC application & then selecting Web API as an option from VS? If WCF is not dying, can you suggest which one is better & how should I use it? Commented May 1, 2014 at 23:42
  • @FreephonePanwal - WebAPI 1.0 is available in MVC4, which is available to be installed in VS2010 SP1 as a download. WCF does a lot more than Web Services, Web API only does Web Services. Commented May 1, 2014 at 23:52
  • ok...So for my requirement, is it a good approach to use WCF by just adding another project & selecting WCF service? Commented May 1, 2014 at 23:54

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

ok..what if I want to add few more such APIs in future (I don't expect it to be more than 7 or 8), do you still recommend for existing MVC controllers that would return JSON? In my case, when I need OS information, I need it in one of my helper class, so just to be clear, I've to have a separate controller which would be accepting input & then return JSON & this controller will be invoked by my helper class?? Any link for tutorial which does it like this?
Also, can my client call this api which is implemented through controller using JSON?
The answer is yes to all the questions. There are good reasons to go to Web API of course - Like support for Help Pages, CORS, Ability to content negotiate and more fine grained control for your JSON responses. Also note they can run in the same application in the future if you change your mind. Here is a link to another thread - stackoverflow.com/questions/18373202/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.