简体   繁体   中英

how to use window.location to call a page method?

I am trying to hit my server side method in my asp.net app. Why is this not working? btw I cant use jquery in this case.

server:

        [WebMethod(EnableSession = false)]
        public static string HelloWorld()
        {
            //do something
        }

client

<script type="text/javascript">
  window.location.href = "http://localhost//default.aspx/HelloWorld";
</script>

Your javascript works for me. Looks like you have an extra / between localhost and default.aspx. Perhaps you mean:

window.location.href = "http://localhost/default.aspx/HelloWorld";

I'd try to log something on the server side, and go to that location directly to see if the server is setup correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM