httputility does not exist in current context in framework 3.5

末鹿安然 提交于 2019-12-10 20:37:32

问题


I'm trying to use HttpUtility.UrlEncode in my sharepoint project in the framework 3.5 but it doesn't recognise it. Simply saying :

HttpUtility does not exist in current context

I called System.Web but it still doesn't recognise none of the Http objects !


回答1:


You need to add a reference to System.Web.dll

A using System.Web without the above reference will not suffice alone.

Unfortunately, the System.Web.dll cannot be referenced in a project that targets a Client Profile version of the .Net framework. So look at your project properties and make sure it targets ".NET Framework 3.5" and not ".NET Framework 3.5 Client Profile".




回答2:


This question was answered here: Alternative to HttpUtility for .NET 3.5 SP1 client framework?

Another option if possible is to upgrade to .NET 4.5 then you have the option of using

WebUtility.UrlEncode 

http://msdn.microsoft.com/en-us/library/system.net.webutility.urlencode.aspx



来源:https://stackoverflow.com/questions/15020802/httputility-does-not-exist-in-current-context-in-framework-3-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!