Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get full servername and port running in mvc 2 by codebehind

hi every body i have a question

example if i have url : http://localhost:8512/bookuser/Create

how to get "http://localhost:8512" by code behind in mvc2 ??

thanks regard

like image 514
amateur Avatar asked Nov 27 '25 20:11

amateur


1 Answers

The following will give you the protocol, host and port part of the request

Request.Url.GetLeftPart(UriPartial.Authority)
like image 182
William Avatar answered Dec 02 '25 02:12

William



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!