c# - How to get current domain name in ASP.NET -



c# - How to get current domain name in ASP.NET -

i want current domain name in asp.net c#.

i using code.

string domainname = httpcontext.current.request.url.host;

my url localhost:5858but it's returning localhost.

now, using project in localhost. want localhost:5858.

for example, when using domain

www.somedomainname.com

i want somedomainname.com

please give me thought how current domain name.

using request.url.host appropriate - it's how retrieve value of http host: header, specifies hostname (domain name) ua (browser) wants, resource-path part of http request not include hostname.

note localhost:5858 not domain name, endpoint specifier, known "authority", includes hostname , tcp port number. retrieved accessing request.uri.authority.

furthermore, not valid somedomain.com www.somedomain.com because webserver configured serve different site www.somedomain.com compared somedomain.com, if sure valid in case you'll need manually parse hostname, though using string.split('.') works in pinch.

note webserver (iis) configuration distinct asp.net's configuration, , asp.net ignorant of http binding configuration of websites , web-applications runs under. fact both iis , asp.net share same configuration files (web.config) red-herring.

c# asp.net

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -