So, i'm a complete noob to C#. I have a url that i need to encode in order to use urlencoded posts.
Issue is, every resource i've found says to use System.Web.HttpServerUtility.UrlEncode. Alternatively, I have seen resources telling me to use System.Web.Util.HttpEncoder().
I have added a reference to system.web, but am getting the "does not exist in system.web namespace" and "does not exist in system.web.util namespace" errors.
Any tips 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);
}
}
}