0

I want to use a javascript uploader in my C# project. The javascript gets loaded in the master page, and in the partial view where I want the uploader to be I have the following code:

   <a class="upload" href="/Administration/blue/en-gb/Entity/StoreFile/97?Entity=Note&amp;Field=File">uploadfile</a>

However, when I click the button I get an '"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." error. The same kind of question can be found here. However, as a solution something like the following is given:

 return Json(new { mymsg = "my msg" }, JsonRequestBehavior.AllowGet);

Where adding JsonRequerstBehavior.AllowGet solves the problem.

In my C# ActionResult that calls the PartialView in which I Want to add this I have this as a return:

return PartialView("CreateNotePartial", Model);

I also tried:

<%$.post('/blag/JSON', function (data) {%>
    <a class="upload" href="/Administration/blue/en-gb/Entity/StoreFile/97?Entity=Note&amp;Field=File">uploadfile
        </a>
 <%});%>

but that did not work.

I can not add the JsonRequestBehavior.AllowGet. How can this be made to work without this .AllowGet?

Community
  • 1
  • 1
Niek de Klein
  • 8,524
  • 20
  • 72
  • 143

1 Answers1

0

This helped me, maybe it will help others too.

public JsonResult AppleAppSiteAssociation()
{
        string json = "{\"applinks\": {\"apps\": [],\"details\": [] }}";
        JsonResult res = new JsonResult();
        res.Data = json;
        res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;

        return res;
}
Leo Muller
  • 1,421
  • 1
  • 12
  • 20