I'm using ASP.Net Ajax through the PageMethods function in Javascript. This function triggers a method on the server without posting the page back. If launch the project with this page as the startup then the web function is working as intended. However, if I navigate away from the page and then navigate back (or start the project with a different page and then navigate to the page in question) then the PageMethods call will run the page load event and not run the web method at any point.
I have these ASP.Net Ajax PageMethods on my Default.aspx page as well and for some reason this page does not have this issue. I can navigate away and then come back and everything still works as intended.
Does anyone know what would cause my other page to execute the page load event and not the web method?
EDIT
Here is a link to an answer on a similar question that worked for me. However, I'm still curious as to why I would need to run this function in order for the PageMethods to work.
https://stackoverflow.com/a/40379421/11466855
From what I'm seeing is that when the page first loads this javascript function will check the PageMethods path and if it doesn't have ".aspx" in the path then it appends that value to the end of it and this caused my issue to go away. I'm curious as to why and what causes the path to not be useable.
Thank you!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…