Solved

Response.Write is not completing output

Posted on 2014-03-25
2
248 Views
Last Modified: 2014-04-10
hi
I have code that creates XML file when user clicks on button. I find that the end of the string is being omitted though. Please advise on this.
It works on windows 2003 but not 2012. The error came around when moving from 2003 to 2012.

       
Public Shared Sub saveToHardDrive(filename As String,
                                          Response As HttpResponse, _
                                          textToWriteToFile As String,
                                          fileExtension As String)
                'response to prompt user to save.
                Response.ClearContent()
                Response.ContentType = "text/plain"

                'replace spaces with %20, prevents IE replacing with _ underscores
                If HttpContext.Current.Request.UserAgent.Contains("MSIE 7.0") Then
                    filename = filename.Replace(" ", "%20")
                End If

                'add XML to filename
                If Not filename.EndsWith(fileExtension) Then
                    filename += fileExtension
                End If
                Response.AddHeader("Content-disposition", "attachment;filename=""" + filename + """")

                Response.Write(textToWriteToFile)


                Response.BufferOutput = True
                Response.Flush()
                Response.Close()
        End Sub

Open in new window

0
Comment
Question by:rwallacej
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
BlueYonder earned 500 total points
ID: 39953100
Check the version of .net framework in use on 2003 then make sure the version is installed on the 2012 server.  Also make sure the target framework is set as shown in http://msdn.microsoft.com/en-us/library/bb772098(v=vs.90).aspx.  The problem may be with framework 4.5 and new namespaces.
0
 

Author Closing Comment

by:rwallacej
ID: 39992153
probably is this, to be checked - ended up moving back to old server though
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question