如何在查询字符串中转义单引号 [英] how to escape single quote in query string
本文介绍了如何在查询字符串中转义单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
i需要使用查询字符串将一个城市名称传递到另一个页面。例如
''Coeur d''Alene''但它仅考虑之前的单引号如''Coeur d''
所以请尽快给我解决方案.......
hi everyone,
i need to pass one city name to another page using query string.its like
''Coeur d ''Alene'' but its considering only before single quote like ''Coeur d''
so please provide me solution soon.......
推荐答案
你可以考虑使用 HttpUtility.UrlEncode
[ ^ ]。这将帮助您转义引号。
You could consider using HttpUtility.UrlEncode
[^]. This will help you escape quote symbol.
在将任何数据添加到查询字符串之前,您应该始终执行Server.UrlEncode
。检索数据后,您应该在查询字符串上执行Server.UrlDecode
以获取实际数据。
http://msdn.microsoft.com/en-us/library/ ms525738(v = vs.90).aspx [ ^ ]
http ://msdn.microsoft.com/en-us/library/6196h3wt.aspx [ ^ ]
before adding any data to the querystring you should always do aServer.UrlEncode
on that. after retrieving the data you should doServer.UrlDecode
on query string to get the actual data out of it.
http://msdn.microsoft.com/en-us/library/ms525738(v=vs.90).aspx[^]
http://msdn.microsoft.com/en-us/library/6196h3wt.aspx[^]
这篇关于如何在查询字符串中转义单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文