Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2015-01-12
11
Medium Priority
?
215 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
CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

 
LVL 9

Accepted Solution

by:
sudheeshthegreat earned 1000 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 1000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

719 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