This is a migrated thread and some comments may be shown as answers.

MVC Grid export with 500 internal error

4 Answers 698 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tomo
Top achievements
Rank 1
Tomo asked on 01 Apr 2015, 03:37 PM
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"))
                                )
                            )

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 03 Apr 2015, 11:54 AM
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.

 
0
Steve
Top achievements
Rank 1
answered on 13 Sep 2016, 07:03 PM
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.
0
Steve
Top achievements
Rank 1
answered on 13 Sep 2016, 07:07 PM
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
0
Steve
Top achievements
Rank 1
answered on 13 Sep 2016, 07:07 PM
Tags
Grid
Asked by
Tomo
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Steve
Top achievements
Rank 1
Share this question
or