MVC Grid export with 500 internal error

5 posts, 0 answers
  1. Tomo
    Tomo avatar
    1 posts
    Member since:
    Apr 2012

    Posted 01 Apr 2015 Link to this post

    I'm having issue with mvc grid export to excel (using 2015.1.318 trial mvc version).   grid populates fine.  export to excel works with smaller records.. but when downloading bigger size of file, it errors as "Failed to load resource: the server responded with a status of 500 (Internal Server Error)"  however, read method /Report/GetGridData controller fine.  it's dynamically creating columns from datatable.   Does anyone have any clue what I might be doing wrong here ?  

    2015.1.318 trial mvc version
    MVC5
    VS2012

    --- controller
            [HttpPost]
            public ActionResult GetGridData([DataSourceRequest] DataSourceRequest request, string spName, string program, string fromDate, string toDate)
            {
                DataTable _dataTable = new DataTable();
                ReportData reportData = new ReportData();
                user = UserManager.FindByNameAsync(User.Identity.Name).Result;
                _dataTable = reportData.GetSPData(spName, user.Id, program, fromDate, toDate);
                return Json(_dataTable.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
            }

    --- cshml

                                    @(Html.Kendo().Grid<dynamic>()
                                    .Name("abcGrid")
                                    .Columns(columns =>
                                    {
                                        foreach (System.Data.DataColumn column in Model.Columns)
                                        {
                                            var c = columns.Bound(column.ColumnName).Title(column.ColumnName).Width(150);
                                        }
                                    })
                                    .Excel(excel => excel
                                        .AllPages(true)
                                        .FileName("abcGridExport.xlsx")
                                        .ProxyURL(Url.Action("Excel_Export_Save", "Grid"))
                                    )
                                    .Pageable()
                                    .AutoBind(false)
                                    .Sortable()
                                    .ToolBar(tools => tools.Excel())
                                    .Filterable()
                                    .DataSource(dataSource => dataSource
                                        .Ajax()        
                                        .Model(model =>
                                            {
                                                foreach (System.Data.DataColumn column in Model.Columns)
                                                {
                                                    var field = model.Field(column.ColumnName, column.DataType);
                                                }                
                                            })
                                        .Read(read => read.Action("GetGridData", "Report").Data("readparameter"))
                                    )
                                )
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 03 Apr 2015 Link to this post

    Hello Tomo,

    What is the actual error message in this case? You can try breaking with the Visual Studio debugger to see what the server exception is.

    Regards,
    Atanas Korchev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Steve
    Steve avatar
    3 posts
    Member since:
    Feb 2015

    Posted 13 Sep Link to this post

    I am having a similar issue. Excel export works with smaller datasets, but returns 500 Internal Server Error for larger datasets. I debug the controller action and it retrieves the data properly. I have jszip bundled correctly. Not using a ProxyUrl, but my understanding is I should not need that with Chrome.
  5. Steve
    Steve avatar
    3 posts
    Member since:
    Feb 2015

    Posted 13 Sep in reply to Steve Link to this post

    OK, I see a similar question that states there is a limit. http://www.telerik.com/forums/excel-export-not-working-with-more-than-a-thousand-records
  6. Steve
    Steve avatar
    3 posts
    Member since:
    Feb 2015

    Posted 13 Sep in reply to Steve Link to this post

Back to Top
UI for ASP.NET MVC is VS 2017 Ready