Can’t get site root url in asp mvc

To get the current host with port (mysite.com, www.mysite.com or localhost:9876)

 Request.Url.Authority

To get your current application folder: (/ or /appfolder/)

 Url.Content("~/")

To mix them?

 String.Format("{0}://{1}{2}",Request.Url.Scheme, Request.Url.Authority,Url.Content("~/"))

OR (As torm pointed out)

 Url.Action("", null, null, Request.Url.Scheme)
 Url.Action("", null, null, "http")
 Url.Action("", null, null, "https") 

To generate an Action URL:

 Url.Action("About","Home",null,"http")

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)