We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Exporting to Excel, Word, PDF Error

I following the document on https://help.syncfusion.com/aspnet/grid/exporting
everything seem no problem on code, but when I clicked the export button the IIS express on VS2017 show an error like below

please help me ~ ~

HTTP Error 405.0 - Method Not Allowed

The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

Most likely causes:

  • The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.
  • A request was sent to the server that contained an invalid HTTP verb.
  • The request is for static content and contains an HTTP verb other than GET or HEAD.
  • A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.

Things you can try:

  • Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.
  • Check the IIS log file to see which verb is not allowed for the request.
  • Check the failed request tracing logs for additional information about this error. For more information, click here.

Detailed Error Information:

Module   DefaultDocumentModule
Notification   ExecuteRequestHandler
Handler   StaticFile
Error Code   0x80070001


Attachment: example_code_af96aee2.rar

1 Reply

VN Vignesh Natarajan Syncfusion Team February 1, 2019 07:40 AM UTC

Hi sengdala, 
 
Thanks for contacting Syncfusion support.  
 
Query: Exporting to Excel, Word, PDF Error 
 
From your query, we understand that you need to export the Grid data to excel format. From the shared sample, we could see that you have not defined the Export functions in the controller page. Due to this the reported issue will occur.  
 
To export the Grid, server side must be configured using any of the available web services, since you have use webAPI controller. We suggest you to refer the below UG documentation how to configure the WebAPi controller for exporting 
 
 
For your convenience we have modified the provided sample, please refer the below code and sample link, 
 
 
var dm = ej.DataManager({ 
            url: "/api/Orders/GetOrders", 
            adaptor: new ej.UrlAdaptor(), 
            enableCaching: false, 
            cachingPageSize: 10, 
            timeTillExpiration: 120000 
        }); 
 
        $("#Grid1").ejGrid({ 
            dataSource: dm, 
              …………….. 
            toolbarSettings: { 
                showToolbar: true, toolbarItems: ['search', ej.Grid.ToolBarItems.ExcelExport, ej.Grid.ToolBarItems.WordExport, ej.Grid.ToolBarItems.PdfExport] 
            }, 
            toolbarClick: function (args) { 
                if (args.itemName == "Excel Export") { 
                    this.export("/api/Orders/ExcelExport"); 
                    args.cancel = true; 
                } 
                else if (args.itemName == "Word Export") { 
                    this.export("/api/Orders/WordExport"); 
                    args.cancel = true; 
                } 
                else if (args.itemName == "PDF Export") { 
                    this.export("/api/Orders/PdfExport"); 
                    args.cancel = true; 
                } 
            }, 
            columns: [ 
                  …………….. 
            ] 
        }); 
 
    </script> 
 
Controller Page 
 
        <ActionName("ExcelExport")> 
        <HttpPost> 
        Public Sub ExcelExport() 
            Dim exp As ExcelExport = New ExcelExport() 
            Dim gridModel As String = HttpContext.Current.Request.Params("GridModel") 
            Dim obj As GridProperties = CType(Syncfusion.JavaScript.Utils.DeserializeToModel(GetType(GridProperties), gridModel), GridProperties) 
            Dim Db As NORTHWNDEntities = New NORTHWNDEntities() 
            Dim result = Db.Orders.ToList() 
            Dim excelExp As GridExcelExport = New GridExcelExport() 
            excelExp.FileName = "Export.xlsx" 
            excelExp.Excelversion = ExcelVersion.Excel2010 
            excelExp.Theme = "flat-saffron" 
            exp.Export(obj, result, excelExp) 
        End Sub 
 
        <ActionName("WordExport")> 
        <HttpPost> 
        Public Sub WordExport() 
            Dim exp As WordExport = New WordExport() 
            Dim gridModel As String = HttpContext.Current.Request.Params("GridModel") 
            Dim obj As GridProperties = CType(Syncfusion.JavaScript.Utils.DeserializeToModel(GetType(GridProperties), gridModel), GridProperties) 
            Dim Db As NORTHWNDEntities = New NORTHWNDEntities() 
            Dim result = Db.Orders.ToList() 
            Dim WordExp As GridWordExport = New GridWordExport() 
            WordExp.FileName = "Export.docx" 
            WordExp.Theme = "flat-saffron" 
            exp.Export(obj, result, WordExp) 
        End Sub 
 
        <ActionName("PdfExport")> 
        <HttpPost> 
        Public Sub PdfExport() 
            Dim exp As PdfExport = New PdfExport() 
            Dim gridModel As String = HttpContext.Current.Request.Params("GridModel") 
            Dim obj As GridProperties = CType(Syncfusion.JavaScript.Utils.DeserializeToModel(GetType(GridProperties), gridModel), GridProperties) 
            Dim Db As NORTHWNDEntities = New NORTHWNDEntities() 
            Dim result = Db.Orders.ToList() 
            Dim PdfExp As GridPdfExport = New GridPdfExport() 
            PdfExp.FileName = "Export.pdf" 
            PdfExp.Theme = "flat-saffron" 
            exp.Export(obj, result, PdfExp) 
        End Sub 
 
 
 
For your convenience we have attached the sample which can be downloaded from below link 
 
 
Please get back to us if you have further queries. 
 
Regards, 
Manivannan Padmanaban. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon