Avaricesoft’s Weblog

Just another WordPress.com weblog

Encoding URL Strings in ASP.net using C#

Posted by avaricesoft on August 4, 2008

<%@ 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>

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>