Friday, 31 March 2017

Get Current Page URL Or Address in MVC Using C#

3/31/2017 - By Pranav Singh 0

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


Now for getting g domain namewith http like http://localhost:59083 below is the code.


string url = Request.Url.GetLeftPart(UriPartial.Authority);


OUTPUT:



Now for getting complete url http://localhost:59083/home/index below is the code.


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:



About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top