C# 在尝试上载文件时,是否要从localhost打开或保存
我正在尝试将文件上载到特定路径 我为此编写了以下代码:C# 在尝试上载文件时,是否要从localhost打开或保存,c#,asp.net,.net,json,asp.net-mvc-4,C#,Asp.net,.net,Json,Asp.net Mvc 4,我正在尝试将文件上载到特定路径 我为此编写了以下代码: try { if (!System.IO.Directory.Exists(fileLocation)) System.IO.Directory.CreateDirectory(fileLocation);
try
{
if (!System.IO.Directory.Exists(fileLocation))
System.IO.Directory.CreateDirectory(fileLocation);
// file.SaveAs(completefilepathWithFile);
file.SaveAs(FileLocationToSaveInDB);
return Json("File Uploaded Sucessfully");
}
catch (Exception)
{
return json("Failed to upload the file");
}
这段代码适用于Firefox和crome
但是给了我IE9的错误
它提示我:
Do you want to openor save (methodname) from localhost?
其内容如下:
我试过:
但是没有帮助
请帮帮我。许多浏览器无法将application/json作为返回内容类型处理。您可以破解响应并使用mime类型text/html返回内容 试试这个:
return Json("FileUploaded successfully", "text/html", System.Text.Encoding.UTF8,
JsonRequestBehavior.AllowGet);
可能是你的ie下载时出现错误的pathit行为fie@Justcode还有其他选择吗?我怎样才能判断我的IE走错了路径?@EhsanSajjad但我正在将文件上传到服务器@engeldimaría你能在jquery中检查它走的是什么路径吗?