不用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. 【RMAN】RMAN脚本中使用替换变量

    [RMAN]RMAN脚本中使用替换变量--windows 下rman全备脚本 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也 ...

  2. Ubuntu 开发环境搭建

    一.修改权限 Ubuntu 用户权限相关命令 - 彭浪 - 博客园 Ubuntu 文件文件夹查看权限和设置权限 - 朝阳的向日葵 - 博客园 二.安装简体中文支持 三.安装搜狗输入法 四.安装Goog ...

  3. Linux系统自动化安装之cobbler实现

    一.cobbler简介 cobbler是快速网络安装linux操作系统的服务,支持众多的Linux发行版本,如redhat|.fedora.centos.debian.ubuntu和suse,也可以支 ...

  4. 华为OSPF与ACL综合应用实例

    实验要求1.企业内网运行OSPF路由协议,区域规划如图所示:2.财务和研发所在的区域不受其他区域链路不稳定性影响:3.R1.R2.R3只允许被IT登录管理:4.YF和CW之间不能互通,但都可以与IT互 ...

  5. Gerrit代码审计系统实战-Gerrit 2.15.14版本快速搭建

    Gerrit代码审计系统实战-Gerrit 2.15.14版本快速搭建  作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Gerrit版本选择 1>.查看Gerrit官网 ...

  6. Python使用pip安装TensorFlow模块

    1.首先确保已经安装python,然后用pip来安装matplotlib模块. 2.进入到cmd窗口下,建议执行python -m pip install -U pip setuptools进行升级. ...

  7. 项目Beta冲刺——凡事预则立

    班级:软件工程1916|W 作业:项目Beta冲刺(团队) 团队名称:Echo 作业目标:规定代码规范,明确冲刺任务与计划 目录 团队博客汇总 讨论组长是否重选的议题和结论 下一阶段需要改进完善的功能 ...

  8. 网站安全DDOS攻击及监测

    一. 监测 在类Unix系统中可以使用top查看系统资源.进程.内存占用等信息.查看网络状态可以使用netstat.nmap等工具.若要查看实时的网络流量,监控TCP/IP连接等,则可以使用iftop ...

  9. ElementUI——动态表单验证

    前言 版本更新迭代的时候,需要用到一个动态表单的功能,ElementUI刚好有教程就改改用咯 步骤 代码 <!-- 手机副号动态表单框 --> <el-form-item v-for ...

  10. JavaScript的深入理解(1)

    (1)什么是JavaScript? JavaScript是一种专为与网页交互而设计的脚本语言,由三个部分组成:(1).ECMAScript :提供核心语言功能.(2).文档对象模型(DOM):提供访问 ...