decode querystring within context.Request

i have an ashx file that requires some query-string values to deliver appropriate images.

The problem is some search engines urlencode then htmlencode those urls in their cache or when they index those.

So for example instead of getting

/preview.ashx?file=abcd.jpg&root=small

i get

/preview.ashx?file=abcd.jpg&root=small

this basically throws off the context.Request.QueryString["root"] so it thinks that there's no variable root

i guess the second key in the querystring is amp;root i.e the part after the & sign.

What i'm wondering is if there's a way to automatically html and urldecode the querystring on serverside so that the program doesn't get confused.

Answers


There is no harm in calling HttpUtility.HtmlDecode or HttpUtility.UrlDecode more than once.

string queryString = "/preview.ashx?file=abcd.jpg&root=small";
var parsedString = HttpUtility.HtmlDecode(queryString);
var root = HttpUtility.ParseQueryString(parsedString)["root"];

Need Your Help

Linking Custom Static Lib with Windows Phone 8 Runtime

windows-runtime windows-phone-8 static-libraries static-linking

I have a custom static library i´m trying to use it with Windows Phone Runtime.

execute perl script as passed argument

windows perl command-line

Im trying to execute a perl script as a passed argument from the command line. I compiled a c file and named it "Test", so trying to pass an argument I try this

Generic ThreadPool in .NET

c# .net multithreading generics threadpool

Here's a relatively common task for me, and, I think, for many a .NET programmer: