I've been working in C# building WinForms for almost 7 years and now I find myself needing to build a website in VB. I am having a heck of a time with a querystring problem, but I bet it will be old news to most of you.
If the querystring comes to me encoded, Request.QueryString fails.
Using the code:
myVar = CInt(Request.QueryString("Var2"))
With the querystring:
myPage.aspx?var1=20&var2=20
Everything works fine.
With the querystring:
myPage.aspx?var1='test'&var2='test' (Which is apparently how it is encoded when the user comes through a search engine.)
The code bombs with the error "Conversion from string to type Integer is not valid." This happens because Request.QueryString does not contain a value for Var2. It's actually now named "amp;Var2".
I figured this would be as easy as calling some type of HTMLDecode of off the request object, but that doesn't exist. And the one that exists in System.Web.HttpUtility only accepts a string as input.
Aside from the fact that tryparse would be better (blah, blah blah) what rookie mistake am I making?
If the querystring comes to me encoded, Request.QueryString fails.
Using the code:
myVar = CInt(Request.QueryString("Var2"))
With the querystring:
myPage.aspx?var1=20&var2=20
Everything works fine.
With the querystring:
myPage.aspx?var1='test'&var2='test' (Which is apparently how it is encoded when the user comes through a search engine.)
The code bombs with the error "Conversion from string to type Integer is not valid." This happens because Request.QueryString does not contain a value for Var2. It's actually now named "amp;Var2".
I figured this would be as easy as calling some type of HTMLDecode of off the request object, but that doesn't exist. And the one that exists in System.Web.HttpUtility only accepts a string as input.
Aside from the fact that tryparse would be better (blah, blah blah) what rookie mistake am I making?