3

I'm working on an MVC application that is utilising SignalR

The controller has...

'GET: Home/DiaryEntries
Function DiaryEntries(<DataSourceRequest> request As DataSourceRequest) As ActionResult
    'get a list of all Headline diary entries
    'removed for brevity... HLDiary list is an IQueryable(Of DiaryEntry)
    'DiaryEntry is an object with 7 properies

    Return Json(HLDiaryList, JsonRequestBehavior.AllowGet)

End Function

My Home/Index view has the following javascript

    function outputHLDiaryEntries() {

        $.getJSON("Home/DiaryEntries", function (json) {

            var out = "";
            var i;

            for(i = 0; i < arr.length; i++) {

                out += '<div class="dOuter"><div class="dRow1">';
                out += '<div class="dDate">' + json.results[i].dDate + '</div>';
                out += '<div class="dRef">' + json.results[i].dRef + '</div>';
                out += '<div class="dTeam">' + json.results[i].dTeam + '</div>';
                out += '<div class="dTeam">' + json.results[i].dCreatedBy + '</div>';
                out += '<div class="' + json.results[i].dType + '">' + json.results[i].dType + '</div></div>';
                out += '<div class="dServers">' + json.results[i].dServers + '</div>';
                out += '<div class="dComment">' + htmlEncode(json.results[i].dComment) + '</div></div>';

            }

            $('#diaryTable').innerHTML = out;

        });
    }

Unfortunately when outputHLDiaryEntries() is called it returns a 500 error

and the error is

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.

As you can see I've allowed Get Behaviour in my function...

Return Json(HLDiaryList, JsonRequestBehavior.AllowGet)

Why is this and how can I fix... I'm out of ideas

James Donnelly
  • 117,312
  • 30
  • 193
  • 198
Mych
  • 2,419
  • 2
  • 31
  • 58

1 Answers1

0

this issue occurred due to CORS (cross origin request).

I think this link will help you !!

Community
  • 1
  • 1
Manoj Verma
  • 354
  • 5
  • 12