473,378 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

get servername

I have a web app that sends an email to user and in the email it provides a
link to a detailed page on their information. My question is, when the email
is sent how can i get the web server name so when they click on the link it
takes them to the web server were the email was generated from?

Nov 18 '05 #1
3 12550
I think you can use the HttpContext class to get the sort of information your
looking for.

"Mike" wrote:
I have a web app that sends an email to user and in the email it provides a
link to a detailed page on their information. My question is, when the email
is sent how can i get the web server name so when they click on the link it
takes them to the web server were the email was generated from?

Nov 18 '05 #2
1. You can use the Dns.GetHostName() to get the server's hostname:

http://msdn.microsoft.com/library/de...tNameTopic.asp

However, the hostname will probably just be a machine name (such as
WEBSERVER1). You can implement mapping logic that says which hostname
maps to which DNS.

2. If you can just use IP's, it's simpler, but a server may have
multiple IP's (such as local 127.x.x.x, internal 10.x.x.x and
external). You can get a list of IP's from a hostname:

IPHostEntry iphostentry = Dns.GetHostByName(strHostName);

// Enumerate IP addresses
int nIP = 0;
foreach(IPAddress ipaddress in iphostentry.AddressList)
{
Console.WriteLine("IP #" + ++nIP + ": " +
ipaddress.ToString());
}

See:
http://www.codeguru.com/Csharp/Cshar...cle.php/c6041/

3. You can use properties in the Request object is you're responding to
an HTTP request. You can parse the Request Server Varibles, but I'd
recommend using the Url's built in parsing features:

Request.Url.GetLeftPart(UriPartial.Authority)
Hope that gets you started.

- Jon
http://weblogs.asp.net/jgalloway

Nov 18 '05 #3
HttpContext.Current.Request.ServerVariables["SERVER_NAME"]
--
Ben Strackany
www.developmentnow.com

"Mike" <Mi**@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
I have a web app that sends an email to user and in the email it provides a link to a detailed page on their information. My question is, when the email is sent how can i get the web server name so when they click on the link it takes them to the web server were the email was generated from?

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tgru | last post by:
I am trying to script out the creation of database scripts. I am trying to use @@servername in the statement. I found out the select @@servername returns NULL. I used sp_dropserver to drop any...
0
by: c.verma | last post by:
I have a web based (forms based authentication) asp.net application that uses .NET remoting. It has web.config.remoting with all the required settings in it. As soon as it tries to access the...
0
by: Siegfried Heintze | last post by:
I have pointed my hosting service to http://support.microsoft.com/default.aspx?scid=kb;en-us;825738 because we are getting an "Unspecified" error when trying to fill my data adapter from an...
2
by: Christina | last post by:
Hello!! I have been researching on this for a while. If someone can show me a pointer it would be great. I have an LDAP server on my local machine. I am creating a new instance of ...
1
by: crystalite | last post by:
Hi all.. I really really need some help here. I have created a login application which is using samples from Microsoft's persistent cookie logon form using Forms authentication. I am using...
1
by: =?Utf-8?B?cm9nZXJfMjc=?= | last post by:
http://www.sqldbatips.com/showarticle.asp?ID=45 the tutorial I am looking at. I copied the last method. and I am using the following references using System; using...
3
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 with Apache 2. How would I get the value of the "ServerName" attribute of the "<VirtualHostdirective in the Apache configuration (httpd.conf) file? I noticed that...
3
by: jantaneey | last post by:
Someone renamed a server from 2A to A. When I do @@servername I get 2A. The server/machine name is 2. Should my triggers say 2A or 2? Does it matter? Thanks
1
by: Mark | last post by:
I am really struggling with this, trying to understand why it doesn't work. I've simplified the code down to the essentials. The GridView displays in ReadOnly mode just fine, Clicking the "edit"...
2
by: Daniel Ngu | last post by:
Hi, I'm in the process of moving a database from a server running Windows 2000 SP4 to a PC running XP SP2. Basically, here's what I've managed to do so far: Made a full backup of the database...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.