使用查询字符串进行编码和解码. c#.net

使用查询字符串进行编码和解码. c#.net

问题描述:



我尝试使用查询字符串进行编码和解码.
在本地主机上成功运行.但是当我在服务器上上传项目时.
那时没有在带有查询字符串的解码页面上接收值.

谢谢,
Pinank,

Hi,

I try encode and decode with query string.
it''s successful run on local host. but when I have upload project on server.
that time not receive value on decode page with query string.

Thanks,
Pinank,

按照以下方式重新编写您的方法...

在父页面编码"查询字符串中,这种方式

公共静态字符串Encode(string sData)
{
返回HttpUtility.UrlEncode(sData);
}

现在,将此编码的查询字符串传递到您的父页面,并在父页面上通过以下函数对该查询字符串进行解码.我假设编码的查询字符串名称为sData,并将其从父页面传递到子页面

公共静态字符串Decode()
{
字符串dSData = HttpUtility.UrlDecode(Request.QueryString ["sData"].ToString());
返回dsData;
}

我想您已经知道如何将查询字符串从父页面传递到子页面
Re write your method following way...

In Parent Page Encode query string this way

public static sting Encode(string sData)
{
return HttpUtility.UrlEncode(sData);
}

Now pass this encoded query string to your parent page & on Parent page decode that query string by following function. I assume that encoded query string name is sData & its passed from parent page to child page

public static string Decode()
{
string dSData = HttpUtility.UrlDecode(Request.QueryString["sData"].ToString());
return dsData;
}

I think you have idea about how to pass query string from parent to child page