HttpUtility is not a member function of web... error in URL encode / decode

Hi @Tech_Guru
Try this for encode url

string url=HttpUtility.UrlEncode(“Example - Google Search”)

Thanks
ashwin S

Hi @Tech_Guru

Try with this System.Net.WebUtility.UrlEncode("URL").

13 Likes

@kuppu_samy 's post should be marked as answer…

1 Like

@lakshman I am trying to parse email address. But i keep getting "httputitlity is not declared error.

"HttpUtility is not declared. It may be inaccessible due to its protection level.

varRealtor1href = javascript:openContactMe(‘https://www.mlsli.com/Content/Forms/ContactMe.aspx?listingagentid=10903990&agentemailaddress=raj@rajhasbuyers.com&subject=Inquiry:%20Listing%20No.%203213038&FormID=2&AgentFlg=1&BRListingFlg=0&ListingSourceID=436&ListingID=295840218&WebsiteID=1016805&IsWebsite=1&IsPrimary=1’);

varRealtor1URL = new Uri(varRealtor1href)
varAgent1EmailAddress = HttpUtility.ParseQueryString(varRealtor1URL.Query).Get(“agentemailaddress”)

image

Hi,

Make sure that you have the following things in your xaml file (open with notepad++ or something similar):

The tag:
mva:VisualBasic.Settings
<x:Null />
</mva:VisualBasic.Settings>”

the NamespacesForImplementation:
“<x:String>System.Web</x:String>”

and the reference added:
“< AssemblyReference>System.Web</ AssemblyReference>” (lose the spaces :wink: )

It should work after reopening the file in Studio.
Thank you

6 Likes

This works for me.

This works for me

Hi @Catalin_Tolea, thanks for your help!

I’m not sure what you mean when you say:

The tag:
“mva:VisualBasic.Settings
<x:Null />
</mva:VisualBasic.Settings>”

Where would I put this in the .xaml file?

But no matter, that tag is not needed to get System.Web.HttpUtility working.

All you need to do is add the “<AssemblyReference>System.Web</AssemblyReference>” line to the list containing all of the AssemblyReference lines and System.Web starts to load the System.Web.HttpUtility and all other Classes.

I wonder why this is? Why do we have to manually add System.Web in this way?

2 Likes

Hi Oscar,

The xaml file is the workflow file in which you have the issue (example: Main.xaml file). You need to open the project with an explorer and locate that file.
You are also right, it could work with your addition but, in some cases, it will work only with the full set explained by me.

This happens only in some cases, where the installation of the activity does not work 100% and we need to add this small piece.

Thank you

1 Like

Thanks for the response! I am still having trouble with this code:

The tag:
“mva:VisualBasic.Settings
<x:Null />
</mva:VisualBasic.Settings>”

Where would I put this in the Main.xaml file, for example? Does it matter? I just don’t know what line to insert it into. Thanks.

Worked like charm

All you need to do is add the “ <AssemblyReference>System.Web</AssemblyReference> ” line to the list containing all of the AssemblyReference lines and System.Web starts to load the System.Web.HttpUtility and all other Classes.

i agree with this and this method works pretty well with me. thanks @oscar

1 Like

As stated in HttpUtility.HtmlDecode Method (System.Web) | Microsoft Learn

To encode or decode values outside of a web application, use the WebUtility class.

With MyString as the variable to encode

System.Net.WebUtility.HtmlEncode(MyString)

2 Likes

this worksss!!!

it works for me, thanks

This also worked for me. The other method regarding adding in System.Web did not work for me (although I did add it in and leave it in before attempting the System.Net.WebUtility method)