.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Problem with closing window in ie 6 sp 3 after download using Response.BinaryWrite

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :ASP.Net
Hi all, I currently having problems in closing a page that launches a download (using Response.BinaryWrite) opened using IE 6 sp 3. All other versions of IE it closes fine. This page was opened using window.open. Below is a sample code of what i am trying to achieve: protected void Page_Load(object sender, EventArgs e) { Response.Clear(); //Specify the document type. Response.ContentType = "application/word"; //Specify how the document is sent to the browser. Response.AddHeader("content-disposition", "attachment; filename=MyDasddsaocument.doc"); //Get data bytes from the file and send it to the response. byte[] bytes = System.IO.File.ReadAllBytes(@"C:\\Temp\\in.doc"); Response.BinaryWrite(bytes); Response.End(); Page.ClientScript.RegisterStartupScript(this.GetType(), "CloseMe", "window.close();", true); } I hope someone can help me with this issue. Thank you in advance.

View Complete Post

More Related Resource Links

Response.BinaryWrite help needed


Hi all

Im new to .NET and stuck now, so i hope anyone can help my with my problem.

I have a MS SQL database where i have stored some documents as Binary data. I cant figure out how to retrieve them and show/download them in my browser.

I found some guides online and have try to put something together.


private void Write()
 int id = 0;
 string strID = Request.QueryString["id"];
 int.TryParse(strID, out id);

 var db = new ModelDataContext();
 var doc = db.DocumentDatas.Where(x => x.ID == id).FirstOrDefault();

 byte[] byteArray = File.ReadAllBytes(doc);


How do i fill the byteArray with the data?

Thanks in advance :)


problem in consuming WCF service through Window application


I have a silverlight application and WCF service all made in VS 2010 , i had hosted my site to web server which contain Window 2008 and IIS 7.0

now the problem is i have another application which is a window application developed in VS2008 , when i try to add the service reference it gives me error


The document at the url was not recognized as a known document type.

The error message from each known type may help you fix the problem:

- Report from 'DISCO Document' is 'There was an error downloading 'http://dev_qa.emspa.com/HRDev3/Service.svc?disco'.'.

  - The request failed with HTTP status 400: Bad Request.

- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

- Report from '' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

Metadata contains a reference that cannot be resolved: ''.

Content Type application/soap+xml; charset

Problem when displaying a popup window

Hi all,
I am working on a project in which when I clicked a hyperlink a pop up window has to be displayed for 2 pages.
But at first when i did this in javascript it worked, later after i finished the whole coding suddenly an error box displayed that there is an error in webpage and want to debug

Closing Javascript Modal dialog window after server side event processing


Hello Friends..

Please tell me how to close Javascript ModelDoalog Window.. after Server Side event Processing .

Basically i want close window in  finally Block After sucessfulll Updation.

AMit..... InnocentInnocentInnocentInnocentInnocentInnocentInnocent

File Download Problem


Hi everyone,

I am using a download handler to handle the downloading of files from my website.  I am using a slightly modified code from the Microsoft article http://support.microsoft.com/kb/812406

Everything is working fine and downloading, even with large files, but it does not show the file size for any of the files to download. Even if theyre really small.

Here is my code for the handler

public class DownloadHandler : IHttpHandler

        public void ProcessRequest(HttpContext context)
            string path = "";
                path = context.Server.UrlDecode(context.Request.QueryString["src"]).DecryptString();
            catch(Exception ex)
            System.IO.Stream iStream = null;

            byte[] buffer = new Byte[10000];

            int length;

            long dataToRead;

            string filename = System.IO.Path.GetFileName(path);

                iStream = new System.IO.FileStream(context.Server.MapPath("~/" + path), System.IO.FileMode.Open,
                            System.IO.FileAccess.Read, System.IO.FileShare.Read);


Problem download file from SQL Server


Hello everyone. I am having an issue downloading files that I have store in SQL Server. I have no problem in a WinForm. What am I doing wrong in my code?

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim sch As New clsReport
        Dim fileData As New clsReport.Letter
        fileData = sch.DownloadLetter(Session("LetterID"))
        Dim ms As System.IO.MemoryStream = fileData.fil

        Dim fil As Byte() = ms.ToArray
        Dim nam As String = fileData.name
        Dim ext As String = fileData.ext
        If Not fil Is Nothing Then
                ' Response.Clear()
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + nam & "." & ext)
                ' Response.AddHeader("Content-Disposition", nam & "." & ext)
                Response.AddHeader("Content-Length", fil.Length.ToString)
                Response.ContentType = "Application/octet-stream"
                Response.Buffer = True
            Catch ex As Exception
            End Try

        End If

    End Su

Problem to install MS SQL 2005 on Window 7 Operating System

Hi, I recently have problem to install MS SQL 2005 on Window 7 Operating System. Setup showing an error for compitability issues. When click on to button to check for solution online, after a while it pop up that No solutions found for Microsoft SQL Server 2005. Any one know solution for this? Is is possible to install Microsoft SQL Server 2008 on Window 7 and migrate data from Microsoft SQL Server 2005 to 2008? Please advice. Appreciate your help. Thanks.

Response.Redirect in new browser window

   protected void ddlPrint_Changed(object sender, EventArgs e)     {         if (ddlPrint.SelectedValue == "All Agenda Items")         {             Response.Redirect(string.Format("{0}?{1}", SettingsRepository.ReportingURL,                                             Utils.EncryptQueryString("ReportName=AgendaItem.rpt")));         }How can I open following report in new browser window using response.redirect? Thx   protected void ddlPrint_Changed(object sender, EventArgs e)    {        if (ddlPrint.SelectedValue == "All Agenda Items")        {            Response.Redirect(string.Format("{0}?{1}", SettingsRepository.ReportingURL,                                            Utils.EncryptQueryString("ReportName=AgendaItem.rpt")));        }}

Problem displaying a page using window.showModalDialog when resizing it.

 Hi, I have a page that is displayed using window.showModalDialog, when the page is resized the tables, text boxes and everything else that is in the page with the width 100% doesn't resize (fit the page) unless a post back is used.How can I make the page keep everything in proportion when it is resized without the need to post back? 

Page does not close after Response.BinaryWrite when opened in IE 6 sp 3

Hi all, I currently having problems in closing a page opened using IE 6 sp 3 after Response.BinaryWrite. All other versions of IE it closes fine. This page was opened using window.open. Below is a sample code of what i am trying to achieve: protected void Page_Load(object sender, EventArgs e) {            Response.Clear();  //Specify the document type.  Response.ContentType = "application/word";  //Specify how the document is sent to the browser.  Response.AddHeader("content-disposition", "attachment; filename=MyDasddsaocument.doc");  //Get data bytes from the file and send it to the response.  byte[] bytes = System.IO.File.ReadAllBytes(@"C:\\Temp\\in.doc");  Response.BinaryWrite(bytes);  Response.End();  Page.ClientScript.RegisterStartupScript(this.GetType(), "CloseMe", "window.close();", true); } I hope someone  can help me with this issue. Thank you in advance.

Client download .csv file from server using Response.TransmitFile

I am using the code below to enable clients to download a .csv file from my server.The problem I am having is that when the file is saved to the client computer the file name is prefixed and suffixed with an underscore which leads to a file type of .csv_ which is obviously not a recognised file type.How can I strip the underscores from the file name at the transmit stage?        Dim FileName As String = LstBox1.SelectedItem.ToString        Dim FilePath As String = "~/temp" & FileName        Response.Clear()        Response.ContentType = "text/csv"        Response.AddHeader("Content-Disposition", "attachment; filename=\" & FileName & "\")        Response.TransmitFile(FilePath)        Response.End() 

How to prevent collapsible panel from closing modal window

I have a collapsible panel extender inside a modal window, my problem is that whenever I click on the link button (to expand my panel), the window closes. Does anyone know of a way to avoid this?

Response.Redirect problem in Google Chrome

I'm building an ASP.NET 3.5 webapplication using VB.NET, and I'm having problems redirecting to another URL when using Google Chrome. Other browsers like IE and Firefox are fine.My data entry forms all have an OK and an Cancel button, which are both handled server-side. The Cancel button just redirects back to the originating page, while the OK button will add or update a database record and then redirect to the originating page.The redirect to the originating page is done by calling the following shared sub on a general utilities class in my appication: Shared Sub Redirect(ByVal p_sURL As String) Dim l_sURL As String = p_sURL.ToLower If Left(l_sURL, 1) = "~" Then Dim l_oControl As New System.Web.UI.Control l_sURL = l_oControl.ResolveUrl(l_sURL) End If If Left(l_sURL, 1) <> "/" Then If Left(l_sURL, 7) <> "http://" AndAlso Left(l_sURL, 8) <> "https://" Then l_sURL = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) & wsUtils.SiteRoot & l_sURL End If End If HttpContext.Current.Response.Redirect(l_sURL) 'HttpContext.Current.Response.Redirect(l_sURL, False) End Sub As you can see, I've tried using the extra argument in the Response.Redirect call, but that

Closing window in javascript without confirmation

Hello! I need to open a browser window without Toolbars, Status bar and Explorer bars (this means no back, refresh, ... buttons, no histiry, no nothing visible in this browser window). This is what I do: from normal browser window I open new window with all the properties I need and than I close the first window: <body>     <script type="text/javascript">  window.open('login.aspx','','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,                        left=0px, top=0px,width=1024, height=768');  window.close();     </script> </body> This would be OK if the first window would just close, but it doesn't. I get the confirmation window with this text: The Web page you are viewing is trying to close the window. Do you want to close this window? I don't want user to have to close the window manually. Can somebody please tell me how to close browser window without the confirmation popup? Thnx in advanced, dvale

Timeout child window problem

The users of our site have reported a problem where when you have a child window open and click around in the main window, the child window will time out even though there is activity in the main window. We use an encryptedFormsAuthenticationTicket and http cookie that expires after a timeout period using Response.Cookies.Add(authCookie). Is there an obvious problem from this description? We are using the back button prevention like so:   Response.AppendHeader("Cache-Control", "no-cache") Response.AppendHeader("Cache-Control", "private") Response.AppendHeader("Cache-Control", "no-store") Response.AppendHeader("Cache-Control", "must-revalidate") Response.AppendHeader("Cache-Control", "max-stale=0") Response.AppendHeader("Cache-Control", "post-check=0") Response.AppendHeader("Cache-Control", "pre-check=0") Response.AppendHeader("Pragma", "no-cache") Response.AppendHeader("Keep-Alive", "timeout=3, max=993") Response.AppendHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT")  Could this cause timeout problems in child windows? Any suggestions?

response.Outputstream problem

I'm trying to get create a page that grabs a file from a directory and streams the binary data to an embedded media player.   When the following code is used on a page that acts as the URL for the embedded media player the player only plays the first 11 seconds and then stops.Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim iStream As System.IO.Stream Dim strFile As String Dim strFolder As String Dim Length As Integer 'strFile = "CFD30HB1404100AD.mpeg" 'strFolder = "C:\wmdownloads" strFile = Request.QueryString("Filename") strFolder = Request.QueryString("Folder") ' Open the file. iStream = New FileStream(strFolder & "\" & strFile, FileMode.Open, FileAccess.Read, FileShare.Read) ' Total bytes to read: Length = iStream.Length Dim Buffer(CInt(Length)) As Byte iStream.Read(Buffer, 0, CInt(Length)) iStream.Close() Response.Clear() Response.ClearHeaders() Response.Charset = "UTF-8" Response.ContentEncoding = System.Text.Encoding.UTF8 Response.ContentType = "video/mpeg" Response.AddHeader("Content-Disposition", "attachment; filename=&

A problem about CreateWindow - "balloon (tool) tip text window"

I dlike to use balloon tool tip text "TTM_ADDTOOL" in global environment. now..,I am using a code which works fine but in the main form - in my own app only..When i use mainwindowhandle of notepad it doesnt works - tooltip is not displayed. When my mouse cursor is away from my form and my mouse cursor is above notepad = tooltip is not displayed. Does exist any solution which will displaying baloon tipText on concrete coordinate? Any idea, solution, link..? more concrete.. I Tryed to create new tip window on concrete coordinate. Code is compiled., without errors, but new window is not visible. Somebody who can help me?   // Create an instance handle. Asm = Assembly.GetExecutingAssembly(); hInstance = Marshal.GetHINSTANCE(Asm.GetModules()[0]); // Create the ToolTip window. WinHandle = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, "Balloon Help Message" , WS_POPUP | TTS_NOPREFIX | TTS_BALLOON, 50, 50, 320, 240, IntPtr.Zero, IntPtr.Zero, hInstance, IntPtr.Zero); //display tool tip ShowWindow(WinHandle, 1);  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend