如何编码URL在JavaScript中,它在C#进行解码 [英] How to encode url in javascript and decode it in C#

查看:166
本文介绍了如何编码URL在JavaScript中,它在C#进行解码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有通过一些数据传递查询字符串的URL。我想在服务器端来检索数据。什么是这个问题。

I have a url with querystrings through which some data are passed. I want to retrieve the data in the server side. What is the solution for this problem

推荐答案

您可以使用JavaScript的转义函数来编码URL的解决方案。

You can use javascript's escape function to encode the URL.

Example : 
escape("It's me!") // result: It%27s%20me%21

URL解码在C#。

Example : 
s = "%46%69%67%68%74%20%74%68%65%20%70%6F%77";
Uri.UnescapeDataString(s); 



编辑-------------------- -----

EDIT -------------------------

解析在C#中使用的查询参数

To Parse Query parameters in C# use

NameValueCollection qscoll = HttpUtility.ParseQueryString(querystring);



希望这会有所帮助。

Hope this will help.

谢谢!

·侯赛因

这篇关于如何编码URL在JavaScript中,它在C#进行解码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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