What's the best method in ASP.NET to obtain the current domain? -
i wondering best way obtain current domain in asp.net?
for instance:
http://www.domainname.com/subdir/ should yield http://www.domainname.com http://www.sub.domainname.com/subdir/ should yield http://sub.domainname.com
as guide, should able add url "/folder/content/filename.html" (say generated url.routeurl() in asp.net mvc) straight onto url , should work.
same answer mattmitchell's modification. checks default port instead.
request.url.scheme + system.uri.schemedelimiter + request.url.host + (request.url.isdefaultport ? "" : ":" + request.url.port)
Comments
Post a Comment