对AllowGet的JSON请求行为

时间:2014-05-25 10:12:30

标签: asp.net-mvc json

这是我的控制器代码:

[HttpGet]
    public JsonResult ImportFilesCombined(ImportFilesModel importFile,ImportFilesModel2 importFile2)
    {
        ImportFiles importFiles = new ImportFiles();
        ImportFiles2 importFiles2 = new ImportFiles2();



        string folderpath = ConfigurationManager.AppSettings["UploadFilePath"];

        string filename = "*";
        string[] fileList = System.IO.Directory.GetFiles(folderpath, filename);//getting the file names from the folder as an array

        List<ImportFilesModel> inputFiles = new List<ImportFilesModel>(fileList.Length);//making a list of same number of elements as the number of files            
        inputFiles = importFiles.GetImportFilesDetails();
                    foreach (string str in fileList)
        {
            ImportFilesModel inputFile = new ImportFilesModel();
            inputFile.FileName = Path.GetFileName(str);
            inputFile.FileSelected = false;
            inputFiles.Add(inputFile);
        }
        List<ImportFilesModel2> inputFiles2 = new List<ImportFilesModel2>();
        inputFiles2 = importFiles2.GetImportFilesDetails2();

        var tuple = new Tuple<List<AetnaCoventryMigration.Model.ImportFilesModel>, List<AetnaCoventryMigration.Model.ImportFilesModel2>>(inputFiles, inputFiles2);

        return Json(tuple, JsonRequestBehavior.AllowGet);        
    }

我收到错误:

  

此请求已被阻止,因为在GET请求中使用此信息时,可能会向第三方网站披露敏感信息。要允许GET请求,请将JsonRequestBehavior设置为AllowGet。

我已经在返回声明中允许它,但仍然会出现错误。

0 个答案:

没有答案