vb UrlEncoding不起作用

时间:2016-08-01 12:57:50

标签: .net vb.net url uri urlencode

您好我使用以下代码在vb中编码网址,但我没有得到预期的输出请帮助。

  Dim CancelURL As String = "http://d41a9833f1464bd0a764b77669049fc8.cloudapp.net/Login/Appointment Booking/CancelAppointment.aspx?" &
                                     "clhid=" & objLogin.LoggedHeadOrgID &
                                     "&apptid=" & objAppt.ID
            strTemplateString = strTemplateString.Replace("[Cancellation link]", Uri.EscapeDataString(CancelURL))

这是我的代码,我最终得到了这个

http%3A%2F%2Fd41a9833f1464bd0a764b77669049fc8.cloudapp.net%2FLogin%2FAppointment%20Booking%2FCancelAppointment.aspx%3Fclhid%3D22b53721-a127-41be-95ca-7512b5caad84%26apptid%3Debb09af1-c521-47d6-9a7d-0b411ef3937d

但我期待

http://d41a9833f1464bd0a764b77669049fc8.cloudapp.net/Login/Appointment Booking/CancelAppointment.aspx?clhid=3D22b53721-a127-41be-95ca-7512b5caad84&apptid=Debb09af1-c521-47d6-9a7d-0b411ef3937d

1 个答案:

答案 0 :(得分:0)

您需要使用Uri.EscapeUriString,因为这不会逃避计划

Uri.EscapeUriString("http://foo.com/this is a url")

'output
http://foo.com/this%20is%20a%20url