A: 

What's wrong with using a relative url?

downLoadUrl = "CertificateDownload.aspx?CertificateID=" + CertificateName

Much simpler.

Sam
I need the absolute url to be displayed as text in the web browser,this not what I need
Ybbest
A: 
Request.MapPath(string.format("CertificateDownload.aspx?CertificateID={0}", CertificateName))
citronas
MapPath returns a physical path for the specified relative url. It doesn't return a URL. It will give very different results than the Url.ToString().Replace() call in the original.
Sam
Why do you need to absolute URL anyway? You said you want the show the links in the Report.aspx. Therefore you don't need absolute URLs here, because when you use a hyperlink mapped with Request.MapPath you will see the absolute URL as it will be displayed in the browser
citronas
That's the requirement, I need the absolute url to be displayed as text in the web browser.
Ybbest
This not what I need ,it will map to a physical path.
Ybbest
+1  A: 

You can do it cleanly with UriBuilder. Some people might say it's overkill, but it makes the intent of the code very clear and it's easier to program and maintain, and less error-prone.

    var uriBuilder = new UriBuilder(HttpContext.Current.Request.Url);
    uriBuilder.Path = Path.GetDirectoryName(uriBuilder.Path) + "/CertificateDownload.aspx";
    uriBuilder.Query = "CertificateID=" + CertificateName;
    var downloadUrl = uriBuilder.ToString();
Sam
Cool,thanks.I will give it a try.
Ybbest
Thanks ,it works and much cleaner than my code.
Ybbest