如何使用asp.net和ASP的URL编码函数 [英] How to use url encoding function between asp.net and asp

查看:363
本文介绍了如何使用asp.net和ASP的URL编码函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个用于asp.net和ASP这两种功能。我想要写两个版本。该函数用于URL连接code和德code。现在,我得到了一个新的问题。这是如何工作的server.urlen code。那么,如何实现这个网址连接code函数。我有一个asp的网址去code函数。我试图让网址为EN ASP code函数。这样一来,我可以写地址的连接code和德code在asp.net中。请帮我。

I want to write the two functions that is used for asp.net and asp. I want to write two version. This function is used url encode and decode. Now, I got a new problem. This is how to work server.urlencode. So, how to implement this url encode function. I have url decode function for asp. I try to get url encode function for asp. So that, I can write url encode and decode in asp.net. Please, help me.

这是网址去code函数。

This is url decode function.

Function URLDecode(sConvert)
    Dim aSplit
    Dim sOutput
    Dim I
    If IsNull(sConvert) Then
       URLDecode = ""
       Exit Function
    End If

    ' convert all pluses to spaces
    sOutput = REPLACE(sConvert, "+", " ")

    ' next convert %hexdigits to the character
    aSplit = Split(sOutput, "%")

    If IsArray(aSplit) Then
      sOutput = aSplit(0)
      For I = 0 to UBound(aSplit) - 1
        sOutput = sOutput & _
          Chr("&H" & Left(aSplit(i + 1), 2)) &_
          Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
      Next
    End If

    URLDecode = sOutput
End Function

这个

推荐答案

VBScript是猪,当涉及到字符串解析所以这里是同德卡code在JScript中完成的:

VBScript is a hog when it comes to string parsing so here is the same decode done in JScript:

<script language="JScript" runat="server">
// This function decodes the any string
// that's been encoded using URL encoding technique
function URLDecode(psEncodeString) 
{
  return unescape(psEncodeString); 
}
</script>

http://www.kamath.com/$c$clibrary/cl006_url。 ASP

.NET有HttpServerUtility.UrlEn code和HttpServerUtility.UrlDe code内置函数。

.NET has HttpServerUtility.UrlEncode and HttpServerUtility.UrlDecode functions built in.

http://msdn.microsoft.com/en-us/library/ 4fkewx0t.aspx

这篇关于如何使用asp.net和ASP的URL编码函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆