| | |
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 3.5 ajax alltypeofvideos appliances asp asp.net bc30451 beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions control countryselector dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash formatdecimal formview gridview gudi iis javascript list listbox login microsoft mouse mssql nameisnotdeclared news novell numerical opera panelmasterpagebuttoncontrols problem radio redirect registration relationaldatabases reportemail save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos vista visualstudio vs2008 web webapplications webdevelopemnt webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers





