Solved

C# Rest Web Services API can only be created using asp.net MVC?

Posted on 2015-01-12
11
210 Views
1 Endorsement
Last Modified: 2015-01-15
Hi, I'm using VS2012.  
I need to create a Rest Web Service program that will consume another web service to get data, re-package it then provide as a web service to another program with this new packaged/formatted data.  
Is the only way to do this in C# is using the MVC model?
I did find a couple of project templates in VS when I click to start new project, "Web Form web API application project template" and "ASP.net MVC Boilerpate".  Which template should I use?
Thank you.
1
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
11 Comments
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 40545429
Actually you can select Web API project from ASP.NET MVC 4 project type dialog, select the as shown here:
http://www.asp.net/web-api/overview/older-versions/build-restful-apis-with-aspnet-web-api
0
 
LVL 9

Expert Comment

by:sudheeshthegreat
ID: 40545585
ASP.NET Web API and WCF are the 2 main ways in which you can create ReSTful services with C# now. There are other ways too, but you probably dont want to unless there are reasons these frameworks cannot provide you with what you need.
0
 

Author Comment

by:lapucca
ID: 40549699
Which is most used now to create REST API?  ASP.NET MVC API or WCF?
So, web api cannot be created using a regular asp.net project template?  It has to be asp.net MVC project template and then select WEB API?

Thank you.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 9

Accepted Solution

by:
sudheeshthegreat earned 250 total points
ID: 40549811
WCF has been around for years since .NET framework 3.0. It is tried and tested, and the good thing about it is that you can simply expose a new endpoint for your service using WebHttpBinding and add some attribute to your service contract for REST Uri paths, and that will give you a RESTful service. If you feel later on that SOAP is better, or that you want to provide both SOAP and REST, you can still do that in WCF.

On the flip side, if you want to provide specific HTTP response codes, such as a 404 or a 503, I am not saying it cant be done in WCF, but ASP.NET Web API makes that simpler. ASP.NET Web Api is fairly recent, and its USP is that it makes it easier to create HTTP web services, and so, if you are building a new RESTful service, this seems to be the future.

I just realized that MSDN also has a page to compare these 2.
http://msdn.microsoft.com/en-us/library/jj823172(v=vs.110).aspx
0
 

Author Comment

by:lapucca
ID: 40549864
Sud, thank you for that break down analysis and the link.  Just one last  question.  Since I'm writing new RESTFUL APIs so I will go with the ASP.NET WEB API , so I have to do this in ASP.NET MVC?  Or can I do this using a ASP.NET web project template?  I mean, when I create a RESTFUL project, what option do I have in Visual Studio 2012 as to what project templates should I use if I'm going with ASP.NET Web API.
Thank you.
0
 
LVL 9

Expert Comment

by:sudheeshthegreat
ID: 40549915
The project templates are a bit different depending on which editor / IDE you use.

With Visual Studio 2013, there's a project template for ASP.NET Web Application, which further lets you choose one or more of Web Forms, MVC, Web API, and so on. So, in your case, you just need to create a project using the ASP.NET Web Application template, and select Web API.

ASP.NET MVC is typically used for creating a website, not a web service. Although there isnt anything stopping you from sending back non-html content (such as json or xml) for all the controllers' actions in MVC either.
0
 
LVL 36

Assisted Solution

by:Miguel Oz
Miguel Oz earned 250 total points
ID: 40549975
As previously stated in my early post, you can select Web API project from ASP.NET MVC 4 project type dialog.
 ASP.NET MVC4 is already included in VS2012,  a gpod example that includes sample code is shown in this link
0
 

Author Comment

by:lapucca
ID: 40550066
I haven't developed in ASP.NET MVS for over 5 years and would rather stick with good old ASP.NET project if I can.  I'm using VS2012 however, I did download the VS2013 but I think that is just the Beta version, can I use VS2013 or should I?  Thank you.
0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 40550081
It is actually easier to work with web api over WCF for REST web service and it can be consumed using C# or Jquery AJAX. There is no need to use MVC constructs if you just want to build a Web API project containing the web service
You do not need VS2013 to use Web api as per info in the links.
0
 
LVL 9

Expert Comment

by:sudheeshthegreat
ID: 40550232
Better to use VS2013 Community Edition.
0
 

Author Closing Comment

by:lapucca
ID: 40551663
thank you both for your great input.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question