How to close current explorer window from C# code.

M

mamin

Hi,
I need to send a file to a client and then close current window.

My code looks as follows:

Response.ContentType="application/bmp";
Response.AppendHeader("","attachment; filename=\"" + bmpFilePath +
"\"");
Response.WriteFile(bmpFilePath);
Response.Flush();
Response.End();

//now I need to close this window.

Anyone know how to do it?
 
Q

q

Depending on the state of the window, you may not be able to. If you
CAN, your best best is to send a JavaScript close command. It's a
major security flaw to allow someone to close your application, so no
browser (not even IE) will allow for that. You need to get user
confirmation...

Start here...

Response.Write("<script>self.close();</script>");
 
M

Mark Fitzpatrick

In addition, I don't thing it would work doing it at the same time because
you would have to write javascript to the browser in addition to sending the
file. The browser is only seeing one stream of data so the javascript would
interfere with the binary stream and render the whole thing corrupt.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top