Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在尝试上载文件时,是否要从localhost打开或保存_C#_Asp.net_.net_Json_Asp.net Mvc 4 - Fatal编程技术网

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中检查它走的是什么路径吗?