Jun 1, 2016
Don Wibier (DevExpress)

DevExtreme: New project template for WebAPI back-end and client (Coming soon in v16.1)

We already had a very nice project template in the previous versions of DevExtreme which allows you to create an OData service based on an existing database in minutes.

The OData protocol is a data access protocol specifically designed to use a uniform way to query and manipulate datasets. As a result, this service includes CRUD operations and execution of paged/sorted queries.

With another project template – The MultiChannel one – you could then create the base for your DevExtreme app including CRUD operations and views. The project template is able to query the meta-data of the OData service to fetch entities as well as fieldnames and types to create JavaScript models and HTML views. Yet another nice feature made possible by the OData protocol.

One of the more difficult aspects of OData are security and identity aspects. This is something easier done with a WebAPI.

Creating a WebAPI back-end in minutes

With the upcoming v16.1 release we have added another project template – DevExtreme WebAPI OData service – which combines the best of both worlds.

DevExtreme Web API Project Template

Once the wizard has finished, you will have a WebAPI project with controllers for all database entities selected in the wizard.

Using MS Identity to secure your WebAPI service

One of the options in the Wizard is whether you want to have Authentication or not. When you select Individual User Accounts, the project will be created including the configuration for MS Identity.

Authentication Options

You can now start securing your Controllers and / or your action methods on the controllers.

namespace MyWebAPIService {
    [Authorize]
    public class InvoiceController : ODataController
    {
        private ChinookConnection db = new ChinookConnection();

        // GET: odata/Invoice
        [EnableQuery]
        [OverrideAuthorization]
        public IQueryable<Invoice> GetInvoice()
        {
            return db.Invoice;
        }

        // ... more code ...
}

Another thing we have configured with the WebAPI service is CORS and JSONP. This means that you can call the WebAPI endpoints from another domain without getting JavaScript errors.

What about the Client App?

Once you try to access the secured WebAPI back-end from within a DevExtreme Client App, you will need to authenticate before data is returned. (You would need a login-view and optionally a registration-view)

We have added additional functionality to our MultiChannel project template which will add the additional views and code for authenticating and registering. We also include a profile view.

Client Applications

If the app tries to access a secure end-point on the WebAPI back-end, you will be automatically taken to the login view to authenticate out of the box!

Windows Phone 10 Support

The last new feature I’d like to mention is that we have deprecated the “cordova-wp8” platform and upgraded to the “cordova-windows” platform.

This means that you are now able to deploy for Windows 8, 8.1 and 10. The result of the deployment wizard will in this case be an .appx package instead of the older .xap package.