Solved

How do I HTML Decode this?

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

http://localhost:3291/default.aspx?un=username&ts=353516603

un is the username
ts is the timestamp

Thanks,
newbieweb
0
Comment
Question by:newbieweb
  • 3
  • 2
  • 2
7 Comments
 
LVL 52

Expert Comment

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

Author Comment

by:newbieweb
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.
0
 
LVL 52

Accepted Solution

by:
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.
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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"]);
0
 

Author Comment

by:newbieweb
ID: 35141702
Will that parse this:

Request.Url.AbsoluteUri;

?
0
 
LVL 33

Expert Comment

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

Author Closing Comment

by:newbieweb
ID: 35141741
Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET - Why is accordion not working? 3 45
Coding for the first time 9 62
WPF user control poped up from a window 1 35
Converting PHP triple des decrypt to c# 9 62
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

713 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