Encoding URL Strings in C#
<%@ Page Language="C#" %> <html> <head> <title>Encoding URL Strings</title> <script runat="server"> void UrlPathEncode() { string StrToEncode; string StrToReturn; StrToEncode = "UrlPathEncode.aspx? Arg = foo"; StrToReturn = Server.UrlPathEncode(StrToEncode); Response.Write("<a href=\"" + StrToReturn + "\">" + StrToReturn + "</a>"); } </script> </head> <body> <% UrlPathEncode(); %> </body> </html>