不用System.Web 对 Content进行编码,De编码

string content = "<br/>";
string s1 = WebUtility.HtmlEncode(content);

string s3 = WebUtility.HtmlDecode(s1);

string s4 = WebUtility.UrlEncode(content);

using System.IO;

namespace System.Net
{
//
// 摘要:
// Provides methods for encoding and decoding URLs when processing Web requests.
public static class WebUtility
{
//
// 摘要:
// Converts a string that has been HTML-encoded for HTTP transmission into a decoded
// string.
//
// 参数:
// value:
// The string to decode.
//
// 返回结果:
// A decoded string.
public static string HtmlDecode(string value);
//
// 摘要:
// Converts a string that has been HTML-encoded into a decoded string, and sends
// the decoded string to a System.IO.TextWriter output stream.
//
// 参数:
// value:
// The string to decode.
//
// output:
// A System.IO.TextWriter stream of output.
//
// 异常:
// T:System.ArgumentNullException:
// The output parameter cannot be null if the value parameter is not null.
public static void HtmlDecode(string value, TextWriter output);
//
// 摘要:
// Converts a string to an HTML-encoded string.
//
// 参数:
// value:
// The string to encode.
//
// 返回结果:
// An encoded string.
public static string HtmlEncode(string value);
//
// 摘要:
// Converts a string into an HTML-encoded string, and returns the output as a System.IO.TextWriter
// stream of output.
//
// 参数:
// value:
// The string to encode.
//
// output:
// A System.IO.TextWriter output stream.
//
// 异常:
// T:System.ArgumentNullException:
// The output parameter cannot be null if the value parameter is not null.
public static void HtmlEncode(string value, TextWriter output);
//
// 摘要:
// Converts a string that has been encoded for transmission in a URL into a decoded
// string.
//
// 参数:
// encodedValue:
// A URL-encoded string to decode.
//
// 返回结果:
// Returns System.String. A decoded string.
public static string UrlDecode(string encodedValue);
//
// 摘要:
// Converts an encoded byte array that has been encoded for transmission in a URL
// into a decoded byte array.
//
// 参数:
// encodedValue:
// A URL-encoded System.Byte array to decode.
//
// offset:
// The offset, in bytes, from the start of the System.Byte array to decode.
//
// count:
// The count, in bytes, to decode from the System.Byte array.
//
// 返回结果:
// Returns System.Byte. A decoded System.Byte array.
public static byte[] UrlDecodeToBytes(byte[] encodedValue, int offset, int count);
//
// 摘要:
// Converts a text string into a URL-encoded string.
//
// 参数:
// value:
// The text to URL-encode.
//
// 返回结果:
// Returns System.String. A URL-encoded string.
public static string UrlEncode(string value);
//
// 摘要:
// Converts a byte array into a URL-encoded byte array.
//
// 参数:
// value:
// The System.Byte array to URL-encode.
//
// offset:
// The offset, in bytes, from the start of the System.Byte array to encode.
//
// count:
// The count, in bytes, to encode from the System.Byte array.
//
// 返回结果:
// Returns System.Byte. An encoded System.Byte array.
public static byte[] UrlEncodeToBytes(byte[] value, int offset, int count);
}
}

C# HtmlDecode、HtmlEncode、UrlEncode、UrlDecode的更多相关文章

  1. Server.UrlEncode、HttpUtility.UrlDecode的区别

    Server.UrlEncode.HttpUtility.UrlDecode的区别 在对URL进行编码时,该用哪一个?这两都使用上有什么区别吗? 测试: string file="文件上(传 ...

  2. Delphi UTF编码 UTF8Encode、UTF8Decode、URLEncode、URLDecode

    一.URL简介    URL是网页的地址,比如 http://www.cnblogs.com.Web 浏览器通过 URL 从 web 服务器请求页面.    由于URL字符串常常会包含非ASCII字符 ...

  3. 各种加密解密函数(URL加密解密、sha1加密解密、des加密解密)

    原文:各种加密解密函数(URL加密解密.sha1加密解密.des加密解密) 普通hash函数如md5.sha1.base64等都是不可逆函数.虽然我们利用php可以利用这些函数写出可逆函数来.但是跨语 ...

  4. PHP获取cookie、Token、模拟登录、抓取数据、解析生成json

    本文介绍使用PHP获取cookie,获取Token.以及模拟登录.然后抓取数据.最后解析生成json的的过程. 0. 设置Cookie路径 set_time_limit(0); //使用的cookie ...

  5. python Django教程 之模板渲染、循环、条件判断、常用的标签、过滤器

    python3.5 manage.py runserver python Django教程 之模板渲染.循环.条件判断.常用的标签.过滤器 一.Django模板渲染模板 1. 创建一个 zqxt_tm ...

  6. 微信公众号开发系统入门教程(公众号注册、开发环境搭建、access_token管理、Demo实现、natapp外网穿透)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/a1786223749/article/ ...

  7. Django drf:cbv源码、resful规范及接口、drf使用、response源码、序列化

    一.cbv源码分析 二.resful规范 三.django中写resful的借口 四.drf写resful的借口 五.APIVIew源码分析 六.drf之序列化 一.cbv源码分析 -CBV和FBV ...

  8. day 87 DjangoRestFramework学习一之restful规范、APIview、解析器组件、Postman等

    DjangoRestFramework学习一之restful规范.APIview.解析器组件.Postman等   本节目录 一 预备知识 二 restful规范 三 DRF的APIView和解析器组 ...

  9. 基础篇-http协议《http 简介、url详解、request》

    目录 一.http 简介 二.url 详解 三.request 1.get 和 post 2.请求方法 3.request 组成 4.请求头 5.get 请求参数 6.post 请求参数 7.post ...

  10. .NET 基础 一步步 一幕幕[面向对象之方法、方法的重载、方法的重写、方法的递归]

    方法.方法的重载.方法的重写.方法的递归 方法: 将一堆代码进行重用的一种机制. 语法: [访问修饰符] 返回类型 <方法名>(参数列表){ 方法主体: } 返回值类型:如果不需要写返回值 ...

随机推荐

  1. IDEA中安装及配置SVN

    1.TortoiseSvn(小乌龟下载地址): https://tortoisesvn.net/downloads.html 2.下载完SVN安装包后,在本机安装SVN(小乌龟),注意安装的时候添加上 ...

  2. day 06 预科

    目录 if判断 if判断习题 for循环 for循环习题 微信机器人 if判断 # 一条狗朝你过来了,你会干吗? 判断: 如果狗是大长腿牵来的狗--->打招呼:如果是条疯狗,跑. # if:如果 ...

  3. PHP实现财务审核通过后返现金额到客户

    应用场景: 有这么一个返现的系统,当前端客户发起提现的时候,后端就要通过审核这笔返现订单,才可以返现到客户的账号里. 来看看下面的截图 这里的业务场景就是经过两轮审核:销售审核,财务审核都通过后,后端 ...

  4. githe和github连接,上传

    Git入门 如果你完全没有接触过Git,你现在只需要理解通过Git的语法(敲入一些命令)就可以将代码上传到远程的仓库或者下载到本地的仓库(服务器),可知我们此时应该有两个仓库,就是两个放代码的地方,一 ...

  5. Hive使用过程中踩过的坑

    hive启动时错误1 Cannot execute statement:impossible to write to binary long since BINLOG_FORMAT = STATEME ...

  6. 倍增法求lca(最近公共祖先)

    倍增法求lca(最近公共祖先) 基本上每篇博客都会有参考文章,一是弥补不足,二是这本身也是我学习过程中找到的觉得好的资料 思路: 大致上算法的思路是这样发展来的. 想到求两个结点的最小公共祖先,我们可 ...

  7. python测试开发django-rest-framework-62.基于类的视图(APIView和View)

    前言 django中编辑视图views.py有两种方式,一种是基于类的实现,另外一种是函数式的实现方式,两种方法都可以用. REST框架提供了一个APIView类,它是Django View类的子类. ...

  8. MySQL——查询优化|47s到0.1s|我做了什么

    前言 这个代码是之前的同事写的,现在我接管了,但是今天早上我打开这个模块的时候发现数据加载异常的缓慢,等了将近一分钟左右数据才显示到页面. 这特么的绝对不正常啊,数据量压根没那么多呀,这特喵的什么情况 ...

  9. vue组件通信方式(多种方案)

    一.Props传递数据 components |-Grandson1.vue //孙子1 |-Grandson2.vue //孙子2 |-Parent.vue //父亲 |-Grandson1.vue ...

  10. 公告 & 备注

    公告 这个\(blog\)从\(2019.12.21\)正式开始使用. 之前的博客请出门右转链接: \[\Large\texttt{my blog}\] \(:)\) 备注 近期要学的算法qwq \( ...