Our domain on the product server has a couple of url rewrites which I think are preventing the jQuery from posting.
I have tried the same script on a domain same server which has no rewrite rules and the script works.
The full script I'm testing is this https://www.aspsnippets.com/Articles/Load-data-while-Scrolling-Page-down-with-jQuery-AJAX-and-ASPNet.aspx
I just can't get my head around how to solve it. I think the rewrite rule causing the issues is the one which creates endless urls which removes the ".aspx" extension from the page name
this is the function
function GetRecords() {
pageIndex++;
if (pageIndex == 2 || pageIndex <= pageCount) {
$("#loader").show();
$.ajax({
type: "POST",
url: "CS.aspx/GetCustomers",
data: '{pageIndex: ' + pageIndex + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}
}
I have tried removing the .aspx in the code above but didn't make any change
The rewrite rules to remove the ".aspx" is this
<rule name="extensionless" stopProcessing="true">
<match url="(.*)\.aspx$" />
<action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
<rule name="removeextension" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.aspx" />
</rule>
The rewrite rules to remove the "&"
<rule name="Rewrite URL to remove & from path." stopProcessing="true">
<match url="^(.*)\:\[20\](.*)$" />
<conditions logicalGrouping="MatchAny" />
<action type="Redirect" url="{R:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
The rewrite rules to remove the "80"
<rule name="Rewrite URL to remove [80] from path." stopProcessing="true">
<match url="^(.*)\:\[80\](.*)$" />
<conditions logicalGrouping="MatchAny" />
<action type="Redirect" url="{R:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
I'm not 100% on why the last 2 rules are in place it must be historic as this is a very old site.
The web config rewrite rules are the only differences between the 2 domains I've tested. Obviously I need to keep the rewrite rules in place and hope someone can help me solve this.
Also if I load the following in the browser
domain.com/CS.aspx/GetCustomers
the page does load
if I load
domain.com/CS/GetCustomers
I get a 404 error
Thanks
I could kick myself
I was calling http instead of https for
and it was getting blocked
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.