2016-08-01 85 views
1

您好我正在使用下面的代码在vb中编码的url,但我没有得到预期的输出,请帮助。vb UrlEncoding不能正常工作

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 
+0

为什么这不是预期的输出?什么*是您的预期产出? –

+0

我需要http://d41a9833f1464bd0a764b77669049fc8.cloudapp.net/Login/Appointment%20Booking/CancelAppointment.aspx?clhid=somevalue like this – Tanmay

+3

不要在评论部分发表实质性澄清;相反,更新你的问题。你需要在问题本身中包含所有相关信息。 –

回答

0

您需要使用Uri.EscapeUriString,因为这不离开方案

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

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