After creating a C# WebMethod, I was able to successfully call it using Ajax, angular, and Postman when adding the header Content-Type: 'application/Json'. Here is an example of the HTTP request that worked:
$http({
url: 'default.aspx/GetPageHtml?file=' + JSON.stringify(selectedFile) + '&page=' + itemNumber,
method: "GET",
headers: { 'Content-Type': 'application/json' },
data:''
}).then(function successCallback(response) {
return response.d;
}, function errorCallback(response) {
});
However, when trying to call the same method as an iframe ng-src, it did not work:
<iframe ng-src="default.aspx/GetPageHtml?file=candy.pdf&page=1" style="height: 150px;"></iframe>
Upon inspecting this Http call through Google Chrome's Developers tools, I discovered that the Content-Type was showing as 'text/html', preventing it from hitting my WebMethod. You can view a screenshot of this issue here.
I searched extensively on Google and Stackoverflow but could not find a reason why I needed to provide Content-Type: 'application/json' in order to call my WebMethod.