Dynamic URL in ASP.NET

Posted on 2009-12-17
Medium Priority
Last Modified: 2012-05-08
I am using ASP.NET 3.5 (VB) to put a link in an email so a user can confirm their subscription.

I want the test link in the email to redirect to:


My code is:

Dim strURL As String = "UserAccountStatus.aspx?action={0}&id={1}"

Dim strDynamicURL As String = String.Format(strURL, "confirm", txtBid_User_ID.Text.ToString.Trim())


' I want to pass this in the email body:
strEmailBody &= "<a href=""<%= strDynamicURL %>""> test</a><br>"

I can't get the above quoted string to resolve correctly in the received email.

Can I do it this way?  Please be very specific in your answer and provide VB code sample.  Thanks.
Question by:KarenH1
LVL 18

Accepted Solution

Rajar Ahmed earned 1000 total points
ID: 26074016
Try this.....
 Dim strDynamicURL As String = "test.aspx"
        Dim strEmailBody As String = "<a href=" & strDynamicURL & "> test</a><br>"

Open in new window

LVL 14

Expert Comment

by:Dhanasekaran Sengodan
ID: 26074076
strEmailBody &= "<a href="&<%= strDynamicURL %>&"> test</a><br>"

Expert Comment

by:Maheshwar R
ID: 26074275
use resolveurl property of ASPwhen calling the url
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 26074281
I'm pretty sure the quotation marks aren't working right.  Try this:

strEmailBody &= "<a href='"<%= strDynamicURL %>"'> test</a><br>"

(I put single quotation marks instead of double quotation marks)

Expert Comment

ID: 26074465
If you do not have HTML mail On, You can not send the LINK ...
But if you spend as direct link works

If you express yourself better, I would answer easier.

Assisted Solution

Sadiko earned 1000 total points
ID: 26074476
I think this way

"<a href=" + strDynamicURL + "> test</a><br>"

Author Closing Comment

ID: 31667446
sAny of the solutions with "<%...%>" gave me "an embedded expression cannot be used.

TThe other two worked fine.  Thanks!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question