This
article will show you how you can get the domain name from the url in your mvc
application. In this I will show few of the ways by which you can get the
detail part values.
Suppose
below is the url:
http://localhost:59083/home/index |
string
url = Request.Url.GetLeftPart(UriPartial.Authority);
|
OUTPUT:
string
url = Request.Url.AbsoluteUri;
|
OUTPUT:
Now for
getting the path “/home/index” below
is the code.
string
path = Request.Url.AbsolutePath;
|
OUTPUT:
Now for
getting the domain name “localhost” below is the code.
string
host = Request.Url.Host;
|
OUTPUT:
0 comments:
Please let me know your view