Adding URL to an email displays ASP.NET exception when accessed
I am currently working on ASP.net c# project. The URL might have spaces e.g. may look like http://www.mydomain.com/my download/index.htm. I am replacing the spaces in the string so it looks like http://www.mydomain.com/my%25download/index.htm.
The email is sent from my ASP.net site without any problems but when I click on the link from inside the email, it displays an error, even though it isn't accessing an ASP.net webpage. The error displayed is 'A potentiall开发者_C百科y dangerous Request.Path value was detected from the client (%).'
I don't understand how it is displaying an ASP.net error when I am not accessing an ASP.net webpage. How can I get round this issue.
A space is encoded as %20
, not %25
. %25
is the %
character, so your sample URL is actually (after decoding) http://www.mydomain.com/my%download/index.htm
. This is what ASP.NET is complaining about.
If you're encoding those URLs manually (string.Replace()
or similar), you'd be better off using the UrlEncode
method of the System.Web.HttpServerUtility
class, accessible as the Server
property of a page.
精彩评论