Skip to main content

WebApi Tutorials

Tutorial HomeWebApi

Learn how to create and use WebApi to provide data to JavaScript SPA apps.

Some notes before we start

WebApi is not directly razor, as it's not meant to actualy render HTML. It's coded using C# just like razor, but won't have commands like @Html.Raw(...). Since it's the best way to communicate from the server with your JavaScript apps, we've included the basics in this tutorial.

Our examples use very trivial JavaScript code to call the API and show the results. Your SPA apps will usually be more sophisticated, but that would then be a topic for a JavaScript tutorial.


Basic WebApi Examples

  1. WebApi - Very basic examples new!
    Creating the simplest possible hello WebApi and a Square(number) Api.
  2. WebApi - Basic example with CSRF protection new!
    This is almost the same as the simplest WebApi, but with additional Cross-Site-Request protection.

WebApi using Polymorph (multiple editions of same API)

  1. WebApi Polymorph - basic examples new!
    Basic example showing the same API in a live and staging editior, so you can develop while the users still use the sable one.

WebApi to access real App Data

  1. WebApi App.Data - basic examples new!
    Basic example reading App Data.
  2. WebApi App.Query - basic examples new!
    Basic example reading App Query.

More Information around WebApi

  1. C# Web API in the 2sxc Wiki
  2. For using the JavaScript