小编Fra*_*ins的帖子

完整的C#noob,VS2010,不能使用HttpServerUtility.UrlEncode?

所以,我是C#的完整菜鸟.我有一个我需要编码的网址,以便使用urlencoded帖子.

问题是,我发现的每个资源都说使用System.Web.HttpServerUtility.UrlEncode.或者,我已经看到资源告诉我使用System.Web.Util.HttpEncoder().

我添加了对system.web的引用,但是得到了"system.web命名空间中不存在"和"system.web.util命名空间中不存在"错误.

任何提示都会很好!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Web;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string url = HttpUtility.UrlEncode("http://stackoverflow.com/");
            MessageBox.Show(url);
        }
     }
}
Run Code Online (Sandbox Code Playgroud)

c# urlencode url-encoding

3
推荐指数
2
解决办法
3073
查看次数

标签 统计

c# ×1

url-encoding ×1

urlencode ×1