当我运行我的项目时,我得到 url http://localhost:5973/PageToPageValuePass/Default.aspx
我想对 URL 进行编码,因为有时我需要在页面之间传输数据。当 url 被编码时,它会增加可靠性。
Server.UrlEncode("http://www.google.com/c#");
我明白了,但是如何使用它来帮助我对 url 进行编码?
最佳答案
如果您对路径的编码部分:
System.Uri.EscapeUriString("c#")
如果您的编码“参数”:
String.Format( "http://something/?test={0}", System.Uri.EscapeDataString("c#") );
关于c# - 如何对 URL 进行编码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1461223/