How can I get the root domain URI in ASP.NET?

后端 未结 14 1447
庸人自扰
庸人自扰 2020-12-12 16:15

Let\'s say I\'m hosting a website at http://www.foobar.com.

Is there a way I can programmatically ascertain \"http://www.foobar.com/\" in my code behind (i.e. witho

14条回答
  •  死守一世寂寞
    2020-12-12 16:38

    This will return specifically what you are asking.

    Dim mySiteUrl = Request.Url.Host.ToString()
    

    I know this is an older question. But I needed the same simple answer and this returns exactly what is asked (without the http://).

提交回复
热议问题