2011-12-13 47 views
0

我正在使用Request.RawUrl獲取localhost後的URL。即如果我的網址是localhost:52482/something/somethingelse,那麼這用於返回/something/somethingelse。我發現如果在頁面中有一些條目,說一些文本框和其他選擇,這將返回一個查詢字符串類型的價值。我該如何解決這個問題?替代爲JavaScript/jQuery中的Request.RawUrl?

我在想在javascript中執行這個操作,看看我是否可以得到沒有查詢字符串的URL。讓我知道我應該如何在這裏繼續?

感謝, 阿達什訥

+0

在服務器端什麼? – KeenUser

回答

2

http://www.w3schools.com/jsref/obj_location.asp

// testsite.com/test.html?q=blah 

var urlWithoutQS = window.location.host + window.location.pathname 

alert(urlWithoutQS);    // testsite.com/test.html 
alert(urlWithoutQS.split('/')[0]); // testsite.com 
alert(urlWithoutQS.split('/')[1]); // test.html 
+0

謝謝,在服務器端的任何替代? – KeenUser

+0

http://msdn.microsoft.com/en-us/library/system.web.httprequest.aspx – Terry