Microsoft Developer Network > Forums Home > Feedback and Discussions Forums > MSDN and TechNet Search Feedback > HTTPS Site Excel Export Error in Asp.net Page Working only on alternative clicks
Ask a questionAsk a question
 

QuestionHTTPS Site Excel Export Error in Asp.net Page Working only on alternative clicks

  • Tuesday, November 03, 2009 12:32 PMBalmurugan Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I am trying to Export content of Asp.net page to Excel it is perfectly working in Dev environment which is not Configured with SSL(Http) but when i move the same code to QA enviromnent which is SSL(Https) enabled it is throwing me an error stating that "Microsfoft Excel could not open the file"   Possible reasons -
    - The file could not be accessed.
    - The path you entered, 'filename', is too long. Enter a shorter path.
    -Filename could not be found. Check the spelling of the filename, and verify that the file location is correct.
    The funny part is it working properly on first click and not working in second click its working on alternative clicks or after 2 or 3 clicks.

    Below is my code Any help would be realy appriciated
    HttpContext.Current.Response.Clear()
    HttpContext.Current.Response.ClearContent()
    HttpContext.Current.Response.ClearHeaders()
    HttpContext.Current.Response.AddHeader(
    "Cache-Control", String.Empty)
    HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName))HttpContext.Current.Response.ContentType = "application/ms-excel"
    Dim m_StringWriter As New StringWriter()
    Dim m_HtmlWriter As New HtmlTextWriter(m_StringWriter)
    gridView.RenderControl(m_HtmlWriter)
    Dim m_gridViewText As String = m_StringWriter.ToString()
    Dim firstStr As String = String.Empty
    Dim scdStr As String = String.Empty

     

    If (gridView.ID = "pnlGainReport") Then
    Dim str1 As String = "<var style='display:none;' id='var1'></var>"
    Dim str2 As String = "<var style='display:none;' id='var2'></var>"
    m_gridViewText = m_gridViewText.Replace(str1, "<table id='tblMain' class='vgroup' cellpadding='0' cellspacing='0'><tr><td>")m_gridViewText = m_gridViewText.Replace(str2, "</td><td>")
    End If
    HttpContext.Current.Response.Write(m_gridViewText)
    HttpContext.Current.Response.End()

    Awaiting any help 


    Thanks and regards
    Bala
     

All Replies