Dynamic URL in ASP.NET

Posted on 2009-12-17
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

    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
    strEmailBody &= "<a href="&<%= strDynamicURL %>&"> test</a><br>"
    LVL 4

    Expert Comment

    by:Mahesh Reddy
    use resolveurl property of ASPwhen calling the url
    LVL 3

    Expert Comment

    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

    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

    I think this way

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

    Author Closing Comment

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

    TThe other two worked fine.  Thanks!

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

    732 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now