This works for me.
Request.Url.OriginalString.Replace(Request.Url.PathAndQuery, "") + Request.ApplicationPath;
- Request.Url.OriginalString: return the complete path same as browser showing.
- Request.Url.PathAndQuery: return the (complete path) - (domain name + PORT).
- Request.ApplicationPath: return "/" on hosted server and "application name" on local IIS deploy.
So if you want to access your domain name do consider to include the application name in case of:
- IIS deployment
- If your application deployed on the sub-domain.
====================================
For the dev.x.us/web
it return this
strong text