I am trying to use C# and Jquery to look and see if a file exists. If it does, then it will download it through a File command, but if it doesn't, then I want to post a message on the screen saying that the file was not found. Everything works, except when I run a cross a file that is not there, I get an error that says:
"This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet."
I tried to allow the get, but it gives me a blank page with the response text on it instead of allowing me to load it into a div tag for display on the page.
Any ideas why it would returning as a Get instead of a POST and how i can modify it to fix the error?
Here is my Jquery code:and my C# codeCode:function SoftwareDownload(FileName) { $('#DownloadResults').text(""); $.ajax ({ url: 'addr', type: 'POST', data: "fileName=" + FileName, dataType: 'json', success: function (response) { $('#DownloadResults').text(response); } }); }Code:public ActionResult SoftwareDownload(string fileName, DownloadModel model = null) { String downloadLocation = (Address is correct ... removing for posting resaons); try { FileStream fs = System.IO.File.OpenRead(downloadLocation + "\\" + fileName); return File(fs, "application/zip", fileName); } catch (Exception) { string response = "File Not Found"; return Json(response); } }



Reply With Quote



Bookmarks