Sending an email with a link that will show the user on a particular page I have!


Basically, I can send the user emails. I tried to send him this:

MailMessage message = new MailMessage()
    Subject = "YOURGURU account",
    Body = "Thanks for joining our site. click th link below to validate your account"+

message.To.Add(new MailAddress("[email protected]", "Some name"));
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.EnableSsl = true;


The HttpContext.Current.Request.Url.Host function appears in the email as "localhost"..but I need it to appear like a real link..that I press and it redirects me. I use visual studio 2010

It seems that you are using


instead of HttpContext.Current.Request.Url

For your local dev environment you will be getting localhost, but when you deploy this to some web server, this would correctly update itself to the hosted web server url.

Ideally, you would have some path that would contain the querystring and then corresponding code in page load to validate and use the querystring.


<br/>"+HttpContext.Current.Request.Url.Host + @"/AccountValidate.aspx?id=SomeId"

Note: You could use the HttpContext.Current.Request.Url also and that would redirect you to the current page with querystring:

<br/>"+HttpContext.Current.Request.Url + "?id=SomeId"

And then in page load of AccountValidate.aspx or current page:

string id = Convert.ToString(Request.QueryString["id"]);
... //Code here to inform the user of successful activation

The important point to consider is that you would need some way to know which user clicked on the activation link, and hence the query string would be of use.

Hope it helps!