使用查询字符串进行编码和解码. c#.net [英] encode and decode with query string. c#.net

查看:98
本文介绍了使用查询字符串进行编码和解码. 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


这篇关于使用查询字符串进行编码和解码. c#.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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