views:

18

answers:

1

I need UrlEncode in my application because i am submitting a form to my server. My app is a quick console utility targeting to .NET 3.5.

The page says i need System.Web assembly, yet when i try to add the reference it isnt there. My WebServer application has it which is also targeted to 3.5 but this console app cant reference it. Why not? how can i access UrlEncode?

+1  A: 

You can - just make sure you've added a reference to System.Web.dll, which may not be in a console project by default.

I suspect this isn't in the Client Profile, mind you - I don't know if that's an issue for you.

I've just tested this with a console app from the command line:

using System;
using System.Web;

class Test
{
    static void Main()
    {
        string text = "hello there";
        string encoded = HttpUtility.UrlEncode(text);
        Console.WriteLine(encoded); // prints hello+there
    }
}

I was able to just compile with

csc Test.cs

but I suspect the default response file contains more assembly references than the default Console Application project template in Visual Studio...

Jon Skeet
Thats the thing, i do see System.Web.* but not system.web. Here is an image http://i30.tinypic.com/jt1e80.jpg As you can see it is .NET 3.5 but not client profile. -edit- note i am using System.Web.Extension for json reasons
acidzombie24
I browsed to the full path (`C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll`) and it worked fine. Weird that it doesnt show in the default add reference window.
acidzombie24
@acidzombie24: That's thoroughly weird. System.Web certainly *should* be available... it is for me, in VS2008. Checking C# Express 2010 now...
Jon Skeet
Were you definitely sorting by Component Name? There's no sort order indicator in your picture. Remove the reference and give it another go :)
Jon Skeet
Ah, that was the problem. It WASNT sorted by name. I thought it would be by default and it seemed to be. Visual Studios 2010 Ultimate.
acidzombie24