[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 489
  • 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
 
newbiewebSr. Software EngineerAuthor 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
 
newbiewebSr. Software EngineerAuthor Commented:
Will that parse this:

Request.Url.AbsoluteUri;

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

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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