0

if my current controller, my URL is:

 http://test.mysite.com/Person/Detail/1

how can i extract into a variable:

  1. Full URL (http://test.mysite.com/Person/Detail/1)
  2. Root url (http://test.mysite.com)

i am sending links inside of emails so i can't just use relative URLs (that why i need something that will get me these URLs

leora
  • 188,729
  • 360
  • 878
  • 1,366

2 Answers2

3
  1. var fullUrl = Request.RawUrl;.
  2. var rootUrl = Request.Url.GetLeftPart(UriPartial.Authority);
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
0

Have a look at this answer it may be of use:

How can I return the current action in an ASP.NET MVC view?

The Uri object is useful when working with URLs also

Community
  • 1
  • 1
Andrew
  • 9,967
  • 10
  • 64
  • 103