user3894984
user3894984

Reputation:

MVC 5 request domain url

im trying to find the domain url in my MVC controller

var currentURL = Request.Url.AbsolutePath ;

this is returning /home/index but notthe domain

any help?

Thanks

Upvotes: 2

Views: 2642

Answers (1)

AlanMorton2.0
AlanMorton2.0

Reputation: 1053

This is what I use in my solution

var currentURL = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host ;

This will return http://www.domain.com

There may be a way to do this better, but this works for me.

Thanks Alan

Upvotes: 1

Related Questions