Building a RESTful API in ASP.NET - asp.net

I have seen a ton of sites on tutorials and how-to's for building your own RESTFul API using ASP.NET. All of them seem to use MVC though. Is it possible to build my own RESTFul API using ASP.NET and WebForms, without using MVC? If anyone has links to a tutorial or something, that'd be great!

Use ASP.NET Web API. It will be the canonical HTTP API server framework moving forward.

Related

angularjs rendering on server side asp.net

I have used angularjs framework for front-end and asp net mvc for back-end to develop my web app. As you know angularjs has a major flaw when it comes to SEO. There are some solutions like using phantomjs to create snapshots of website and serve it to search bot instead of original website. But I don't like it that way. I've recently introduced to the concept of isomorphic web apps and if I'm not mistaken it is possible to pre-render angularjs apps on server and then serve the rendered html to client. All solutions I've found was for other frameworks. Like Rendr (https://github.com/rendrjs/rendr) or angularjs-server (https://github.com/saymedia/angularjs-server). Also there is a library called NodeServices (https://github.com/aspnet/NodeServices) that do the trick but it's written in Asp.net core and angular 2 universal that I use neither of them. Is there any library doing the same work for asp.net and angular?
Thanks in advanced.
As stated here How do search engines deal with AngularJS applications?
Google now execute javascript when crawling the web. The problem is that a there's no standard, ,you can't assume that any search engine will correctly crawl your web application when is client-side rendered.

Can I enable MVC on my ASP web site?

I have a regular ASP.net website and I want to use RESTful API's. Can I use this without creating a new MVC site within Visual Studio?
Perhaps this can help you if you want to make use of ASP.NET MVC Web API in a web forms project to implement your RESTful API
If you want to mix in general ASP.NET MVC into an existing Web Forms application you could try something like this. There should also be a fair amount of literature on SO and the web on how to mix the two together in one project/solution

Is there any ASP MVC 3 framework for a restful api?

I've been doing some digging in the web but all i find is either incomplete guides to do it by yourself or guides for the first version of MVC.
Is there any framework for getting a RESTful API or not?
And if no, is there anyway to add a global solution for all models (extending the model or routing of MVC it self), because what i've read involves adding the REST logic to each model/ controller of the application (Which don't look like a good solution to adopt REST)
WCF Web API for MVC3
Add WebAPI support to MVC3 application
Both of these should give you an idea of what's involved.
Are you able to start using MVC4?

Is there an equivalent to ASP.NET Web API in the Rails world?

Or is Rails by itself just good for developing APIs?
It seems that ASP.NET Web API project types have some history intertwined with WCF (as is detailed in this post for example), so maybe it's not applicable to Rails.
UPDATE
To clarify, Microsoft has the ASP.NET MVC framework. Recently, they came out with a framework called ASP.NET Web API. ASP.NET Web API seems to have similarities to ASP.NET MVC, but is specialized and trimmed down for RESTful web services. Is there an equivalent in the Ruby/Rails space?
So, the answer is Yes to both questions. Rails does have an equivalent and its Rails.
ASP.NET Web API looks like at it's heart is just a RESTful router with type negotiation. I could be totally off base here, but from the tutorials I saw that's what it looked like to me.
So yes, from what I can tell, Rails supports most of the things that the Web API was created for. In fact in Rails most of this stuff is forced onto you until you become informed enough to be able to change it (assuming by that point you know better than to actually do that).
But, as far as Web API functionality. That really comes from the ability to support HTTP verbs (GET, POST, PUT, DELETE) which Rails does.
But a source of confusion might be that in Rails the RESTful API is actually the application itself. Meaning you don't need to implement any other libraries, it's just built that way.
Here's a quick example of that I mean
When you hit /users/1 you will get the data associated with that user depending on the format you requested. So if you request JSON the controller returns JSON, HTML you get HTML, XML you get XML, etc. (As long as said format is implemented for that resource)
A good overview of what I'm talking about are in these two sections:
Rails Guides::Controller: Rendering xml and json data
Rails Guides::Routing: Resources on the Web
So you could build a website, API, or both in a Rails app and they would all start the same way.
But from my limited knowledge on the matter, I would say a ASP.NET MVC with ASP.NET Web API program is actually a lot more like a Rails Program than the regular ASP.NET MVC programs that came before them.
Or it's all just a clever ploy to get as many Capital Letters in a title as humanly possible.
Take a look at grape. It is a pure "Rest" HTTP API framework in ruby.
WSO2 looks like a generic web services framework (as opposed to MVC like Rails) I can't vouch for it but it seems to be more a service framework in the style of WCF Web API (service in the generic sense, not just SOAP).
It's difficult to know what you mean by "APIs"... Rails and ASP are used for developing web sites, and WCF is essentially a web service platform. ASP and WCF have little in common, it's just normal for ASP applications to consume WCF services because they all run on the same stack and platform.
I suppose Rails on the Microsoft side would be a combination of ASP.NET MVC, Linq2SQL or EntityFramework and some WCF.
Ok, this isn't a direct answer to your question, however there seems to be some confusion... Microsoft's ASP.NET Web API is specifically a product offering with ASP.NET MVC 4+. It is a RESTful framework. How does it compare to RoR? I don't know having never tried to install RoR on Windows. As with anything else, experiences vary... Requirements vary. Also try to think ourside the language, construct, context, and framework. Is it better for developing API's? If you're using Linux/Unix, the answer is probably a yes. If you're on a Windows server, the question is a bit trickier.
Finally,
Writing in the ASP.NET Web API will have 0% to do with WCF. Perhaps it is implemented as such under the covers, but the ASP.NET Web API is (from what I've seen and done with it) strictly an HTTP bound API, not TCP/Binary/Piped/etc... like WCF. If you're ask
Yes. It's called Grails. It uses spring. There are tons of plugins available for it and it make creating webapps a breeze. Read more about it here.

Guide for creating ASP.NET MVC RESTful API on Azure

I want to create a simple ASP.NET MVC RESTful API, but I want to create it on Azure.
Any recommendations, tips & tricks, or examples on how to do this?
You may want to look out for this book: Building RESTful Web Applications with Microsoft Azure when it is released.
Also Effective REST Services via .NET has a great section on REST with Azure.

Resources