Schneider
Schneider

Reputation: 2506

How to substract current url in C#?

I want to get root url?

@Request.Url.AbsoluteUri

This is example if i have somthing like this

http://www.example.com/contact if I am on page contact page I want to get this like http://www.example.com is this possible?

Upvotes: 0

Views: 63

Answers (2)

Raja Nadar
Raja Nadar

Reputation: 9499

var baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);

Upvotes: 1

Morten Anderson
Morten Anderson

Reputation: 2321

To get base URl use

Request.Url.Authority 

Upvotes: 0

Related Questions