smcculloch posted on May 08, 2006 07:29

I had an interesting issue today when sorting out an issue with Subscription Tools.
The crux of the issue revolved around a redirect to PayPal for payment. When the redirect is formed a number of parameters are appended to the querystring, including the notification URL for IPN (Instant Payment Notification). This worked great in DNN 3.x (ASP.NET 1.1), but formed a different URL when using DNN 4.x (ASP.NET 2).
The two params that were different were:-
http://www.test.com/ipn.aspx?param=http%3a//test.com/ipnhandler.ashx (ASP.NET 1.1)
and the problem URL:-
http://www.test.com/ipn.aspx?param=http%3a/test.com/ipnhandler.ashx (ASP.NET 2.0)
The issue is that the 2nd URL only has a single / at the http://, I checked some code in the Commerce Starter Kit, but it was identical, and I could only assume the problem was occurring because of ASP.NET 1.1 code running on ASP.NET 2.0.
Originally I thought it was occurring in the encode, but the actual problem occurs in the Response.Redirect, somewhere in that function, the //'s are converted to a single / (I must reflector it). The temporary solution is to create my own redirect method for this page, and here it is:-
Public Sub Redirect(ByVal url As String)
If (url Is Nothing) Then
Throw New ArgumentNullException("Url is Nothing!")
End If
If (url.IndexOf(ChrW(10)) >= 0) Then
Throw New ArgumentException("Cannot Redirect To Newline")
End If
Response.Clear()
Response.StatusCode = 302
Response.RedirectLocation = url
Response.Write("<html><head><title>Object moved</title></head><body>" & ChrW(13) & ChrW(10))
Response.Write(("<h2>Object moved to <a href='" & HttpUtility.HtmlEncode(url) & "'>here</a>.</h2>" & ChrW(13) & ChrW(10)))
Response.Write("</body></html>" & ChrW(13) & ChrW(10))
Response.End()
End Sub