Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Finding the current domain address using MVC

    • 0
    • 1
    • 1
    • 4
    • 0
    • 0
    • 0
    • 0
    • 264
    Comment on it

    I came across a requirement where i had to find the current domain address of the app as i had to send an email to users with a public page url. I knew the virtual address of page but it would not work as in order to open a page from my website using that email link, i had to provide the complete address of webpage. This is the solution i found for this issue.

      string baseDomain = Request.RequestUri.Scheme + System.Uri.SchemeDelimiter + Request.RequestUri.Host + (Request.RequestUri.IsDefaultPort ? "" : ":" + Request.RequestUri.Port);
    

    This gave me the URL of my base domain i.e. https://localhost:44300/

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: