Mehul Harry's DevExpress Blog

This Blog

News


Mehul Harry is the DevExpress Web Program Manager. Follow him on twitter: @Mehulharry

Subscribe (RSS, Email)

Archives

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

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

Published Oct 02 2017, 11:05 AM by
Filed under: , ,
Bookmark and Share

Comments

Edgar Ricardez

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

October 2, 2017 8:32 PM

Steven Olensky

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

October 3, 2017 12:17 AM

Mehul Harry (DevExpress)

@Edgar,

Thanks, fixed the link. It's here:

js.devexpress.com/.../Prerequisites_and_Installation

October 3, 2017 11:13 AM

Mehul Harry (DevExpress)

Steven,

Yes, please check here:

js.devexpress.com/.../Data_Binding

October 3, 2017 11:14 AM

Steven Olensky

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

October 9, 2017 7:00 AM

Mehul Harry (DevExpress)

@Steven,

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

October 12, 2017 11:16 AM

douglas fabiano

Hello..

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

October 17, 2017 1:01 PM

Mehul Harry (DevExpress)

@Douglas,

Yes, please take a look at this:

www.youtube.com/watch

October 17, 2017 2:53 PM

DevInfox

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

October 19, 2017 3:33 PM

Mehul Harry (DevExpress)

@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.

October 20, 2017 10:44 AM

DevInfox

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

October 20, 2017 12:50 PM

Mehul Harry (DevExpress)

October 20, 2017 1:15 PM

About Mehul Harry (DevExpress)

Mehul Harry is an ASP.NET technical evangelist at Developer Express. You can reach him directly at mharry@DevExpress.com. You can also follow him on Twitter: http://twitter.com/mehulharry
LIVE CHAT

Chat is one of the many ways you can contact members of the DevExpress Team.
We are available Monday-Friday between 7:30am and 4:30pm Pacific Time.

If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

FOLLOW US

DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

Copyright © 1998-2017 Developer Express Inc.
All trademarks or registered trademarks are property of their respective owners