我有一个Web方法:PageMethods在ASP.NET无法工作,如果你有ASP.NET路由实现
[System.Web.Services.WebMethod]
public static string getCharacterstics(int product_id, int lang_id)
{
// code goes here...
}
我想用PageMethods喜欢访问: (前提是我必须启用条件在ScriptManager的PageMethods):
<script type="text/javascript">
$(document).ready(
function() {
$('#characterstics').html("loading");
// '<%= product_id_property %>' , '<%= this.LanguageID %>'
PageMethods.getCharacterstics(0 ,0 , OnSave);
}
);
function OnSave(result) {
}
</script>
我得到错误“的HTTP动词后访问路径..是不允许的”
我GOOGLE了它和搜索也是如此,但确实不是G et关于它的任何解决方案基于ASP.NET路由。
我相信是因为asp.net路由服务方法不可访问。
另外我想我甚至不能使用JSON,因为asp.net路由也是如此。
任何帮助表示赞赏。
更新时间:
如果我运行这个网址的页面:
http://localhost:2606/searchdetail.aspx
成功执行Web方法。
现在
我有路由这样的:
routes.MapPageRoute("searchdetail", "searchdetail/{ID}", "~/searchdetail.aspx");
routes.MapPageRoute("searchdetail", "searchdetail", "~/searchdetail.aspx");
的set_path()只会工作的情况下,2即没有ID,但如果我尝试
不符合的情况下1工作
http://localhost:2606/searchdetail
它正常工作
,但如果我尝试使用:
http://localhost:2606/searchdetail/123
它给出了预期的对象错误。
所以set_path()是我应该写的选项。
我尝试使用set_path,但它不起作用。我也更新了我的问题 – Moons
感谢Neha我完成了。其实我正在使用js引用:而不是。这就是为什么你的查询一开始并不适合我。我用小提琴手来找出问题 – Moons