2011-10-27 22 views
0

我想在我的asp.net應用程序中打我的服務器端方法。爲什麼這不起作用?順便說一句,我不能在這種情況下使用jQuery。如何使用window.location調用頁面方法?

服務器:

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

客戶

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

回答

0

您的JavaScript爲我工作。看起來你有一個額外的/ localhost和default.aspx。也許你的意思是:

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

我想嘗試在服務器端登錄一些東西,並直接去那個位置,看看服務器是否安裝正確。

+0

我很困惑它不起作用:( – user603007

+0

哪部分不適合你?如果你在firebug/chrome中的一個javascript控制檯,並且你鍵入window.location ...這是否工作?或者你會去到的位置,並獲得asp.net記錄任何東西? – uncreative