I use System.Web.Services.WebMethodAttribute to make a public static method of an ASP.NET page callable from a client-side script:
test.aspx.cs
[System.Web.Services.WebMethod] public static string GetResult() { return 'result'; }
test.aspx
<asp:ScriptManager ID='sm' runat='server' EnablePageMethods='true' /> <script type='text/javascript'> alert(PageMethods.GetResult()); </script>
The method works as it should, but if I load test.aspx with
Server.Transfer('test.aspx');
I receive ‘Unknown web method’ error. After
Response.Redirect('test.aspx');
the page works well.
Could you tell me, please, what is a reason of the error and how can it also be avoided? Many thanks!
It seems calling set_path solves the problem: