The problem is as follows. I send a request to the server as follows.

$http({ url: url, method: "GET", mimeType: "text/html; charset=UTF-8", params: { groupId: groupId }, headers: { "Header-Type": "charset=UTF-8", "Accept-Language": "en-US,en,ru-ru" } }).then(function (result) { if (result.data !== "") { $scope.filterDetails = result.data; filterList = decodeURIComponent(escape(result.headers("filterList"))); $scope.isListEmpty = false; } else { $scope.isListEmpty = true; } }, function (result) { alert(result.data); }); 

in the controller add header filterList.

  List<SiteFilter> result = SiteFilterRepository.GetFilterList(groupId); JavaScriptSerializer serializer = new JavaScriptSerializer(); string str = serializer.Serialize(result); Response.HeaderEncoding = Encoding.UTF8; Response.AppendHeader("filterList", str); Response.Charset = "utf-8"; if (result != null) { return View("~/Views/SavedSearches/SavedSearchesDetails.cshtml", groupId); } else { return View("~/Views/SavedSearches/SavedSearchesDetails.cshtml", groupId); } 

Which looks like this

 [{\"Id\":85,\"FilterGroupId\":68,\"Parameter\":\"CallId\",\"Condition\":\"Π Π°Π²Π½ΠΎ\",\"Value\":\"4\"}]" 

In Google Chrome and Firefox, it works fine, but not in IE 11. In the line filterList = decodeURIComponent(escape(result.headers("filterList"))) gives an error ΠžΠ±Π½Π°Ρ€ΡƒΠΆΠ΅Π½Π° нСдопустимая ΠΊΠΎΠ΄ΠΈΡ€ΠΎΠ²ΠΊΠ° ΠΏΡ€ΠΈ ΠΏΠΎΠΏΡ‹Ρ‚ΠΊΠ΅ дСкодирования URI .

  • What is the reason for this sophisticated way to return data to the calling code? - teran

1 answer 1

I decided this as follows. I code in the controller in escape sequence, as follows.

  string str = serializer.Serialize(result); string res= HttpUtility.UrlPathEncode(str); Response.AppendHeader("filterList", res); 

In JavaScript, I decode the escape sequence.

  filterList = decodeURIComponent(result.headers("filterList"));