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

July 2013 - Posts

  • SEO Friendly URLs for Paging now supported by DevExpress MVC GridView

    Learn how to enable search engine optimized (SEO) URLs for your DevExpress ASP.NET MVC GridView extension.

    What is ‘SEO Friendly’?

    SEO or search engine optimization means that you’ve optimized your website forsearch engines like Google, Bing, Yahoo, etc. Search engines prefer to link a direct URL with some content.

    Callbacks Issue

    The problem arises because of AJAX callbacks that only update part of the page. AJAX is great for user experience but not for a search engine that wants a static page and URL so that it can be cached in their system.

    DevExpress Solution

    Many DevExpress ASP.NET products provide AJAX callback functionality built into the ASP.NET products. So, to enable SEO friendly mode for DevExpress ASP.NET MVC GridView’s pager, you’ll need to set your view to look something like this:

    @Html.DevExpress().GridView(
        settings = > {
            settings.Name = "grid";
            settings.CallbackRouteValues = new { Controller = "GridView", Action = "SEOFriendlyPagingPartial" };
            settings.Width = Unit.Percentage(100);
    
            settings.KeyFieldName = "CustomerID";
            settings.Columns.Add("ContactName").SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
            settings.Columns.Add("CompanyName");
            settings.Columns.Add("City");
            settings.Columns.Add("Region");
            settings.Columns.Add("Country");
    
            settings.Settings.ShowGroupPanel = true;
            settings.SettingsPager.PageSize = 10;
            settings.SettingsPager.SEOFriendly = SEOFriendlyMode.Enabled;
            settings.SettingsPager.PageSizeItemSettings.Visible = true;
        }
    ).Bind(Model).GetHtml()

    Specifically, the SettingsPager.SEOFriendly property tells the DevExpress MVC GridView to render direct links for the pages. Therefore, when each page of the GridView has a direct link like this one below:

    (Online demo for SEO Friendly feature)
    http://demos.devexpress.com/MVC/GridView/SEOFriendlyPaging?seogrid=page4|size10|sort1|a0 

    The seogrid variable in the above URL contains the information that is parsed by the DevExpress MVC GridView when it loads that page. Therefore, it’s possible for you navigate to a direct page with just the URL.

    Web Crawlers Only

    But what if you wanted to provide a good AJAX experience for your end-users with callbacks while still getting some google-juice for SEO purposes? DevExpress MVC GridView has an answer for you here as well.

    Set the DevExpress MVC GridView’s Pager to SEOFriendlyMode.CrawlerOnly and the GridView renders hyperlinks in the pager when a web-crawler is detected. For other visitors, standard pager links are generated. So, search engines can index the entire contents of the grid and site visitors experience the same callback functionality.

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