Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 486
  • Last Modified:

How do I HTML Decode this?

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
newbieweb
Asked:
newbieweb
  • 3
  • 2
  • 2
2 Solutions
 
Carl TawnSystems and Integration DeveloperCommented:
That URL isn't encoded. What is it you think needs decoding?
0
 
newbiewebAuthor Commented:
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
 
Carl TawnSystems and Integration DeveloperCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Todd GerbertIT ConsultantCommented:
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
 
newbiewebAuthor Commented:
Will that parse this:

Request.Url.AbsoluteUri;

?
0
 
Todd GerbertIT ConsultantCommented:
Ahh... I type slow. ;)
0
 
newbiewebAuthor Commented:
Thanks!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now