Below is a source code snippet that demonstrates how to obtain the current domain in the controller of the ASP.NET MVC 4 Web Application.
How to Retrieve the Current Domain in ASP.NET MVC?
public ActionResult Index() { string Domain = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port); return View(Domain); }
Leave a Reply