How do I HTML Decode this?

Posted on 2011-03-15
Last Modified: 2012-05-11
Using C# and Server.UrlDecode() I need to decode this Uri, but I'm not quite sure how to.


un is the username
ts is the timestamp

Question by:newbieweb
  • 3
  • 2
  • 2
LVL 52

Expert Comment

by:Carl Tawn
ID: 35141628
That URL isn't encoded. What is it you think needs decoding?

Author Comment

ID: 35141643
I just need to grab the two values without using string parsing. I though there was a simple way to get the values out.
LVL 52

Accepted Solution

Carl Tawn earned 350 total points
ID: 35141681
There is:
string un = Request.QueryString["un"];
int ts = int.Parse(Request.QueryString["ts"]);

Open in new window

The values are in the Querystring, but they aren't encoded. You would of course want to sanity check those first to make sure they are valid.
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

LVL 33

Assisted Solution

by:Todd Gerbert
Todd Gerbert earned 150 total points
ID: 35141695
I'm with carl_tawn, not quite sure what the question is, but taking a stab in the dark:

1. Retrieving QueryString parameters would done like: string username = Request.QueryString["un"];, or string tsVal = Request.QueryString["ts"];

2. If you just stuck "username" in there as an example, and the actual URL is http://localhost:3291/default.aspx?un=newbie%20web, then you can still just use Request.QueryString["un"] and the .Net runtime will decode it for you (in this case would get the value "newbie web").

3. If you need to manually URL decode something Server.UrlDecode should do the tring, Server.UrlDecode("http://localhost:3291/default.aspx?un=newbie%20web") = "http://localhost:3291/default.aspx?un=newbie web"

4. Need the "ts" parameter as an int and not a string, then Int.Parse it: int ts = Int32.Parse(Request.QueryString["ts"]);

Author Comment

ID: 35141702
Will that parse this:


LVL 33

Expert Comment

by:Todd Gerbert
ID: 35141704
Ahh... I type slow. ;)

Author Closing Comment

ID: 35141741

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question