[英]C# jQuery Ajax Post Getting Blocked by IIS Rewrite Rule
我们在产品服务器上的域有几个URL重写,我认为这阻止了jQuery的发布。
我在没有重写规则的域同一台服务器上尝试了相同的脚本,并且该脚本有效。
我只是无法解决该问题。 我认为导致该问题的重写规则是一种创建无尽网址的网址,该网址会从页面名称中删除“ .aspx”扩展名
这是功能
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);
}
});
}
}
我尝试删除上面代码中的.aspx,但未进行任何更改
删除“ .aspx”的重写规则是这样的
<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>
重写规则以删除“&”
<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>
重写规则删除“ 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>
我不是100%为何为何要制定最后2条规则,因为这是一个非常古老的网站,所以必须具有历史意义。
Web配置重写规则是我测试过的两个域之间的唯一区别。 显然,我需要保留重写规则,并希望有人可以帮助我解决这个问题。
另外,如果我在浏览器中加载以下内容
domain.com/CS.aspx/GetCustomers
页面加载
如果我加载
domain.com/CS/GetCustomers
我收到404错误
谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.