如果您已实施ASP.NET路由,则ASP.NET中的PageMethods无法正常工作
发布时间:2020-05-23 22:57:00 所属栏目:asp.Net 来源:互联网
导读:我有一个网络方法: [System.Web.Services.WebMethod]public static string getCharacterstics(int product_id, int lang_id){ // code goes here...} 我想使用PageMethods访问它,例如: (假设我在ScriptManager中启用PageMethods的条件):
|
我有一个网络方法: [System.Web.Services.WebMethod]
public static string getCharacterstics(int product_id,int lang_id)
{
// code goes here...
}
我想使用PageMethods访问它,例如: <script type="text/javascript">
$(document).ready(
function () {
$('#characterstics').html("loading");
// '<%= product_id_property %>','<%= this.LanguageID %>'
PageMethods.getCharacterstics(0,OnSave);
}
);
function OnSave(result) {
}
</script>
我得到错误“http动词帖子访问路径..是不允许的” 我搜索了它并搜索了SO,但没有得到任何有关它的解决方案基于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()是我应该写的选项. 解决方法目前,WebMethods不能与Routing框架透明地工作.有一个工作.您必须通过在javascript中执行以下操作直接访问PageMethods:PageMethods.set_path('/the/path/to/your/page.aspx');
PageMethods.YourMethod(params,onSuccess,onFailure);
我希望这有帮助. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- .net – %中的含义是什么:和%=有什么区别?
- Asp.Net Web Api基于令牌的授权,没有OWIN和AspNet.Identity
- asp.net-mvc-4 – ASP.NET帮助页面默认主页?
- asp.net – 绑定ListView InsertItemTemplate中的DropDownL
- asp.net – Html.Partial()跳过控制器动作
- asp.net-mvc – ASP.NET MVC 4 Web API无法映射包含字符串“
- asp.net-mvc – 从MVC版本1迁移后,ASP.NET MVC 2 actionlin
- 为什么调试器不会在我的ASP.NET应用程序的断点处停止?
- asp.net-mvc – Html.BeginForm使用FormMethod.GET丢失rout
- asp.net-mvc – Html.HiddenFor值属性未设置
推荐文章
站长推荐
- asp.net-mvc – 如何检测不引人注目的验证是否成
- asp.net-mvc-3 – Apress Pro Asp.net MVC框架3
- asp.net-mvc – 具有默认日期的MVC4日期选择器
- 如果DataSource不包含任何项目,如何在ASP.NET C#
- asp.net-mvc – 使用@ Html.DisplayNameFor()与P
- 为什么我需要停止使用%= ...%来渲染并开始使用
- asp.net-core – 是否可以直接在Azure WebApps中
- 什么是部署ASP.Net Web应用程序的好方法?
- asp.net-mvc – 使用复杂类型嵌套对象的bind属性
- asp.net-mvc – 如何从ActionExecutingContext获
热点阅读
