Why is System.Web.HttpUtility.UrlEncode giving namespace name doesn't exist in Visual C# 2008?

前端 未结 4 1306

I\'m trying to encode a URL using the HttpUtility.UrlEncode() method, why am I getting

The type or namespace name \'HttpUtility\' does not e

相关标签:
4条回答
  • 2021-02-02 11:11
    1. click on project tab in menu
    2. click on Add References
    3. in References window click on Framework and check the System.Web
    0 讨论(0)
  • 2021-02-02 11:18

    For people using .NET 4.0 or later, you can use WebUtility.UrlEncode which works with client profile (does not require System.Web assembly reference).

    0 讨论(0)
  • 2021-02-02 11:27

    Just in case anyone stumbles across this, is running VS 2010 and cannot find System.Web in the available references...

    Right click on the project and select Properties, if the Target Framework is set to ".Net Framework 4 Client" then change it to ".Net Framework 4".

    But beware this will close, reopen and rebuild your project (also if you have a web service references these will need to be refreshed)

    0 讨论(0)
  • 2021-02-02 11:33

    You need to include a reference to System.Web. Right-click your project in the Solution Explorer and choose Add Reference... . If you take a look at MSDN you'll see it's contained in the System.Web.dll assembly, as far as I remember, this is not referenced by default in new projects.

    0 讨论(0)
提交回复
热议问题