Server.HTMLEncode Problem

Results 1 to 3 of 3

Thread: Server.HTMLEncode Problem

  1. #1
    Join Date
    Dec 1969
    Posts
    109

    Default Server.HTMLEncode Problem

    Hi,<BR><BR>I have an asp which, if certain criteria are met, redirects the<BR>user to another page and passes a variable along with it. I use<BR>the Server.HTMLEncode method on the variable because it may <BR>contain spaces. When I run the asp in IE, it works ok. When I<BR>use Netscape (tried versions 3 & 4), the value of the variable<BR>is not encoded (i.e. spaces have not been encoded as %20) and<BR>the following error message is produced:<BR><BR>HTTP Error 400<BR>400 Bad Request<BR>Due to malformed syntax, the request could not be understood by the server. The client should not repeat the request without modifications.<BR><BR>I can get around the problem by using the Replace function but<BR>I want to know why Server.HTMLEncode doesn&#039t work (for me) in<BR>Netscape.<BR><BR>Below are the two test scripts I wrote. Any comments appreciated. Thanks!<BR><BR>test1.asp<BR>&#060;% @Language = "VBScript" %&#062;<BR>&#060;% Option Explicit %&#062;<BR>&#060;%<BR>Dim Name<BR>Name = Server.HTMLEncode("John Q. Public")<BR>response.redirect "test2.asp?Name=" & Name<BR>%&#062;<BR><BR>test2.asp<BR>&#060;% @Language = "VBScript" %&#062;<BR>&#060;% Option Explicit %&#062;<BR>&#060;html&#062;<BR>&#060;head&#062;&#0 60;title&#062;&#060;/title&#062;&#060;/head&#062;<BR>&#060;body&#062;<BR>&#060;%= request.querystring("Name") %&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;<BR><BR><BR>Oliver

  2. #2
    Nathen Grass Guest

    Default RE: Server.HTMLEncode Problem

    You would want to use Server.URLEncode in this situation. HTMLEncode allows you to output strings that contain characters that normally would be processed by the web browser or the server like HTML tag brackets(&#060; or &#062;) or ASP code brackets (&#060;% or %&#062;).

  3. #3
    Join Date
    Dec 1969
    Posts
    109

    Default RE: Server.HTMLEncode Problem

    Thank-you, thank-you, thank-you!<BR><BR><BR>Oliver, asleep at the wheel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •