| | |
how letting the user open a file without showing message of (Open,Save,cancel)
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2007
Posts: 3
Reputation:
Solved Threads: 0
hi all,
i have a list of some files on the server.
i want to let the user choose a file from the list then click a button to open read-only version from this file without showing the popup message that ask user to Open, Save or Cancel.
this is because i don't want to give the user choice to download the file on his local machine.
the used code is as the following:
i searched about solve to this issue and i found some advices to change the parameter of the "Response.AppendHeader" function and i tried to follow it as u can see in the commented code but this was not helpful.
i want to solve this problem even the way is through IIS.
any1 has any advices i will be grateful if he/she helped me with it.
thanks for advance.
NAHR ELGANNAH.
i have a list of some files on the server.
i want to let the user choose a file from the list then click a button to open read-only version from this file without showing the popup message that ask user to Open, Save or Cancel.
this is because i don't want to give the user choice to download the file on his local machine.
the used code is as the following:
ASP.NET Syntax (Toggle Plain Text)
private void DownloadFile(string fname) { string myPath = Path.GetFullPath(fname); string name = Path.GetFileName(myPath); string ext = Path.GetExtension(myPath); string type = ""; // set known types based on file extension if (ext != null) { switch (ext.ToLower()) { case ".htm": case ".html": type = "text/HTML"; break; case ".txt": type = "text/plain"; break; case ".doc": case ".rtf": type = "Application/msword"; break; case ".xls": type = "Application/excel"; break; default: type = "text/plain"; break; } } Response.Buffer = true; Response.AppendHeader("content-disposition", "attachment; filename=" + name); //Response.AppendHeader("Pragma","cache"); //Response.AppendHeader("Expires", "-1"); if (type != "") Response.ContentType = type; Response.WriteFile(myPath); Response.End(); }
i searched about solve to this issue and i found some advices to change the parameter of the "Response.AppendHeader" function and i tried to follow it as u can see in the commented code but this was not helpful.
i want to solve this problem even the way is through IIS.
any1 has any advices i will be grateful if he/she helped me with it.
thanks for advance.
NAHR ELGANNAH.
•
•
Join Date: Jul 2007
Posts: 24
Reputation:
Solved Threads: 0
Re: how letting the user open a file without showing message of (Open,Save,cancel)
0
#2 Aug 8th, 2007
•
•
Join Date: Aug 2007
Posts: 3
Reputation:
Solved Threads: 0
Re: how letting the user open a file without showing message of (Open,Save,cancel)
0
#3 Aug 9th, 2007
thanks Khaled for reply
if i removed this line, it would work fine with some file types (e.g. .doc), but with others e.g.(.txt, .log etc...) it open the file entire the explorer and with other type (e.g. .xls) it prombt the user to Open, Save or Cancel.
if there is solution for this issue, plz send me
and thank you Khaled again
(JAZAK ALLAH KHAIRAN)
if i removed this line, it would work fine with some file types (e.g. .doc), but with others e.g.(.txt, .log etc...) it open the file entire the explorer and with other type (e.g. .xls) it prombt the user to Open, Save or Cancel.
if there is solution for this issue, plz send me
and thank you Khaled again
(JAZAK ALLAH KHAIRAN)
•
•
Join Date: Jul 2007
Posts: 24
Reputation:
Solved Threads: 0
Re: how letting the user open a file without showing message of (Open,Save,cancel)
0
#4 Aug 11th, 2007
•
•
•
•
thanks Khaled for reply
if i removed this line, it would work fine with some file types (e.g. .doc), but with others e.g.(.txt, .log etc...) it open the file entire the explorer and with other type (e.g. .xls) it prombt the user to Open, Save or Cancel.
if there is solution for this issue, plz send me
and thank you Khaled again
(JAZAK ALLAH KHAIRAN)
Khaled
•
•
Join Date: Aug 2007
Posts: 3
Reputation:
Solved Threads: 0
Re: how letting the user open a file without showing message of (Open,Save,cancel)
0
#5 Aug 12th, 2007
![]() |
Similar Threads
- Doesn't open for file input successfully.... why? (C++)
- Can seem to open my file (C++)
- open a file and divide its data in arrays (C)
- Open any file and List. (Visual Basic 4 / 5 / 6)
- Bubble sort & File output jibrish errors??? (C)
- Error message when trying to open an external file in C++ program (C++)
- Cannot open file : a (Windows 95 / 98 / Me)
Other Threads in the ASP.NET Forum
- Previous Thread: Excel macros with asp.net
- Next Thread: how do I view my home page in IIS?
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn checkbox child click commonfunctions compatible confirmationcodegeneration content contenttype courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dropdownmenu edit expose feedback flash flv form formatdecimal forms formview gridview homeedition iframe iis javascript jquery listbox login menu microsoft mono mouse mssql multistepregistration news numerical objects order panelmasterpagebuttoncontrols parent radio ratings reportemail rotatepage save schoolproject search security serializesmo.table silverlight smartcard software sql-server sqlserver2005 suse textbox tracking typeof unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webprogramming webservice xml youareanotmemberofthedebuggerusers





