Use DevExtreme ASP.NET MVC Controls easily in ASP.NET Core 2.0

February 2018 Update: Take a look at this webinar: Use DevExtreme ASP.NET MVC Controls easily in ASP.NET Core 2.0

These File->New project templates can also help you get started.


In August 2017 Microsoft released the ASP.NET Core 2.0 framework. This major update packs a lot of new features as their announcement blog post makes clear:

This release features compatibility with .NET Core 2.0, tooling support in Visual Studio 2017 version 15.3, and the new Razor Pages user-interface design paradigm. For a full list of updates... -Microsoft Announcement blog post

We've been working hard to provide compatibility with this new release and I'm happy to announce that our DevExtreme ASP.NET MVC controls now support ASP.NET Core 2.0.

To get ASP.NET Core 2.0 in Visual Studio 2017 15.3.x, please check this link: https://www.microsoft.com/net/core

To learn more details about ASP.NET Core 2.0, please see this detailed blog post: https://blogs.msdn.microsoft.com/webdev/2017/08/14/announcing-asp-net-core-2-0/

Get started

To get started with ASP.NET Core 2.0 and DevExtreme MVC Controls in just a few minutes, create an ASP.NET Core 2.0 project using VS2017 and then add DevExtreme MVC Controls resources to it using this guide (see "ASP.NET Core MVC" section):

DevExtreme ASP.NET MVC Controls: Download and Installation

In this screenshot of the Solution Explorer, you see the necessary DevExtreme packages and files that you'll need for ASP.NET Core 2.0:

Upgrade Existing Projects

To upgrade your existing ASP.NET Core 1.x application that is based on *.csproj and includes DevExtreme MVC Controls, you'll need to make the following changes:

  1. Change the "TargetFramework" in your *.csproj file:
<PropertyGroup>
  <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
  1. Replace "Microsoft.AspNetCore.*" packages with the new "Microsoft.AspNetCore.All" meta package:
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />

Your csproj file should look something like this:

Then run your upgraded project and the DevExtreme ASP.NET MVC Controls will work in ASP.NET Core 2.0:

Razor Pages

As part of ASP.NET Core 2.0, Microsoft also introduced 'Razor Pages', which makes page-focused scenarios easier and more productive:

Razor Pages allow you to code without the need for a controller, for example:

We tested the DevExtreme ASP.NET MVC Controls with the new Razor Pages feature and it works brilliantly. Here's the DevExtreme ASP.NET MVC DataGrid that's bound to a WebAPI web service in a Razor Page:

Are you using DevExtreme MVC Controls with ASP.NET Core 2.0? I'd love to hear about it, drop me a line below. Thanks!

Twitter: @mehulharry


Create highly responsive web apps for touch-enabled devices and traditional desktops.

From desktops to mobile devices, DevExtreme HTML5 Data Grid delivers the flexibility you’ll need to build apps that reach the widest audience and deliver touch-first user experiences to power your next great interactive website.

Download a free and fully-functional version of DevExtreme now: Download DevExtreme

14 comment(s)

Link to DevExtreme ASP.NET MVC Controls: Download and Installation is not found, please fix. Thanks

2 October, 2017

Can you give an example of how you added the webapi to this project?

3 October, 2017

@Edgar,

Thanks, fixed the link. It's here:

js.devexpress.com/.../Prerequisites_and_Installation

3 October, 2017

Steven,

Yes, please check here:

js.devexpress.com/.../Data_Binding

3 October, 2017

Mehul,

Razor Pages are great and I fully understand calling WebApi from DevExtreme Controls.

Have you thought of calling Handlers on the Razor Page instead of Api? I can almost get it working except that I always get a 400 (Bad Request) error because Core 2.0 by default turns on AntiForgery Tokens on a POST or PUT.

Look at...

docs.microsoft.com/.../razor-pages

9 October, 2017

@Steven,

Could you please post your sample that produces this error to our support team so they can look into it? Thanks.

12 October, 2017

Hello..

is there any possibility of the ASP.NET MVC component running with ASP.NET Core 2.0 in linux?

17 October, 2017

@Douglas,

Yes, please take a look at this:

www.youtube.com/watch

17 October, 2017

Have the same calling Handlers on Razor Pages question

Like Steven "Have you thought of calling Handlers on the Razor Page instead of Api?"

There is no sample in the binding documentation for Razor Pages Handler

the Code .- Your Documentation ....

the .DataSource(ds => ds

       .Mvc()

       .Controller("GridData")

There is not controller in the Razor Pages - only Page Behind

19 October, 2017

@Steven and @DevInfox,

I discussed this with the team lead and here's his response:

Good question. We asked this ourselves the same day we learned about Razor pages. I suggest to take into account what the Microsoft ASP.NET developers said in this recent interview: channel9.msdn.com/.../C9L11

4:40 “We use controllers for API portions... Always loved using controllers for APIs because it feels natural”

7:40 “Or you want to return JSON (don’t tell anyone I said that). But if you want to, you can”

The above is a clear indication that controllers are the way to go for API requests and using Razor pages for them is not recommended.

However, in the next release, v17.2, we are introducing a new way to configure datasource with arbitrary URLs (not necessary generated by the routing mechanism). This will work with Razor handlers well if you want to use them:

community.devexpress.com/.../devextreme-asp-net-mvc-controls-improvements-amp-new-features-in-data-sources-coming-soon-in-v17-2.aspx

Thanks.

20 October, 2017

I looked at the video with your old buddy Seth , right after the 4:40 maker My take is that they are pushing Razor Page benefits not the other way, instead of a Model. View model, Controller, Views  Folders and cshtml for each page

I see the benefit of just creating a Razor Page and the VM behind , I can still use the Old way if a need to as well  , so I wonder when can I try it with v17.2

20 October, 2017

Hi

I know this post is old already but as today (Feb 14th, 2018) VS2017 dropped Bower. I have created a DevExtreme 17.2 project using the template and it uses Bower. Do you have any documentation how to create a DevExtreme project without Bower?

Thank you.

14 February, 2018

Hi Wilfredo,

I've got a webinar on this that may help: www.youtube.com/watch

Also, VS2017 does support Bower packages. Right-click on your project and select 'Manage Bower Packages'.

You can also use our File->New templates:

js.devexpress.com/.../Project_Templates

14 February, 2018

Please login or register to post comments.