ASP.NET Programmatically retrieving the root domain

I’m developing a web application in and I wanted to know what the URL I was running on, for example  I hate hard coding things or making assumptions.  Also when uploading to different servers, it would mean things should just work and we all like it when things actually do just work. 🙂

So here’s how you do it :


Always so simply, when you know how.

1 comment

  1. Nice post. I learn something totally new and challenging on blogs I stumbleupon everyday.

    It will always be exciting to read content from other authors and use something from other sites.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.