简体   繁体   中英

.Net 2.0 HttpUtility.UrlEncode issue

I am working with a project in .Net 2.0, this must stay in .Net 2.0 I have no way around this as this is what the customer wants.

I am trying to create a string that is going to url encode this

HttpUtility.UrlEncode(key);

However, I get the message

HttpUtility does not contain a definition for UrlEncode

Looking at MSDN here https://msdn.microsoft.com/en-us/library/system.web.httputility.urlencode(v=vs.80).aspx I see that this should be easily possible.

I have my using statement bringing in System.Web and it is in my references too.

Any ideas on what I need to do?

If you are having trouble with system.web use the alternate method as shown in this blog. Html-and-Uri-String-Encoding-without-SystemWeb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM