Full C # noob, VS2010, can't use HttpServerUtility.UrlEncode?

So, I am a complete noob for C #. I have a url that I need to code to use urlencoded messages.

The problem is that every resource found says it uses System.Web.HttpServerUtility.UrlEncode. Alternatively, I saw resources that told me to use System.Web.Util.HttpEncoder ().

I added a link to system.web, but I get "does not exist in the system.web namespace" and "does not exist in the system.web.util namespace errors".

Any advice would be nice!

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);
        }
     }
}
+3
source share
3 answers

, .NET 4, System.Web.dll - . , "" ".NET Framework 4" , " .NET Framework 4". System.Web.

( , . , using . using System.Web, HttpServerUtility System.Web.)

, , Uri.EscapeDataString Uri.EscapeUriString. . , - : (

+6

System.Web :

alt text

+5

, System.Web.dll.

- . - , , , System.Collections, Windows Forms System.Windows.Forms, -, .

. , , .

System.Web using:

using System.Web;

, System.Web.HttpUtility HttpUtility, , System.Web.

Windows , System.Web.dll . , System.Web .

To add a link to the physical library file, right-click on the "References" folder, select "Add Link ..." and select System.Web.dll .

And, again, namespaces are just logical groupings, assemblies are physical files on your hard drive.

Good luck Dan

+1
source

Source: https://habr.com/ru/post/1767035/


All Articles