TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
BLove
NA
3
0
How do I get just the domain name from current user?
Nov 27 2007 9:39 PM
I need to know the exact the domain name that the user is requesting. I am currently using Request.ServerVariables["HTTP_HOST"] but doesn't give eactly what I need. For example, if the HTTP_HOST is:
www.mydomain.com
mydomain.com:8080
abc.mydomain.com
xyz.mydomain.com:5000
I need all these to return "mydomain.com". Also if the website is called with localhost or IP address, I need that returned without flaw either (such as localhost or 66.34.23.99). What's the best way to do this? I need to make sure the domain is only return since my application uses this info to differentiate different domain names pointing to the same web application. Any solid RegEx out there to do this or maybe something native to C#?
Reply
Answers (
1
)
Help me build this program for my class...
NO! Don't crash!