Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  169] [ 6]  / answers: 1 / hits: 22794  / 8 Years ago, thu, september 1, 2016, 12:00:00

I'm searching a way to get the root URL of my Web project; as example:



Local:



http://localhost:52390/pages/user.aspx



Expected result: http://localhost:52390



IIS:



http://lst.pg.com/iLearn/pages/user.aspx



Expected result: http://lst.pg.com/iLearn



Exists a way to achieve this in ASPX? Or in Javascript/jQuery?


More From » jquery

 Answers
1

ASPX: Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath



Implemented with Javascript:



<script type=text/javascript>
var rootUrl = '<% =(Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath) %>';
</script>

[#60842] Tuesday, August 30, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zachariaho

Total Points: 34
Total Questions: 87
Total Answers: 100

Location: England
Member since Tue, Sep 8, 2020
4 Years ago
;