Solved

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

Posted on 2015-01-12
11
197 Views
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.
0
Comment
Question by:lapucca
  • 4
  • 4
  • 3
11 Comments
 
LVL 35

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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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 35

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 35

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now