سلام عليكم
بداية جزاكم الله خيرا لزيارة الموضوع
انا اريد ان اجعل اليوزر يفتح ملف من على السيرفر للقراءة فقط.
الكود الذي استخدمه يظهر لليوزر رسالة تساله اذا كان يريد ان يحفظ هذا الملف ام يفتحه
(Open, Save or Cancel)
وانا لا اريد ان اعطي اليوزر اختيار ان يحفظ الملف.
الكود كالاتي
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();
}
وكنت بحثت على حل لهذه المشكلة ووجدت بعض الناس نصحو بتغيير ال
parameters of "Response.AppendHeader" function
وكما ترون في ال
commented code
حاولت استخدم هذه التغييرات ولكنها فشلت
هل عند احد اي نصائح لهذه المشكلة ؟ وهل هناك طريقة لحل هذه الطريقةمن خلال ال
IIs
مثلا?
في انتظار ردودكم
جزاكم الله خيرا
أخوكم
نهر الجنة