Click here to Skip to main content
14,424,458 members
Rate this:
Please Sign up or sign in to vote.
See more:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pagina3.aspx.cs" Inherits="pagina3" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

 <html xmlns="" >
 <head id="Head1"  runat="server">
 <title>HttpUtility Example</title>
 <form id="form1"  runat="server">
 The raw url is: <br />
 <asp:Label id="UrlRawOutput"
 runat="server" />
 <br /><br />
 The url encoded is: <br />
 <asp:Label id="UrlEncodedOutput"
 runat="server" />
 <br /><br />
 The url decoded is: <br />
 <asp:Label id="UrlDecodedOutput"
 runat="server" />
 <br /><br />
 The query string NameValueCollection is: <br />
 <asp:Label id="ParseOutput"
 runat="server" />

using System;
 using System.Collections.Specialized;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Web;
 using System.Web.UI;
 using System.Web.UI.WebControls;

 public partial class pagina3 : System.Web.UI.Page
 protected void Page_Load(object sender, EventArgs e)
 String currurl = HttpContext.Current.Request.RawUrl;
 String querystring = null;

 // Check to make sure some query string variables
 // exist and if not add some and redirect.
 int iqs = currurl.IndexOf('?');
 if (iqs == -1)
 String redirecturl = currurl + "?email=mAKq7tfZb9zufXHN5TyPMAxNgQhaTjbtPiidyqdXSBA=&valor=XOCf2J+PiAVo5SBiYbly2w==";
 Response.Redirect(redirecturl, true);
 // If query string variables exist, put them in
 // a string.
 else if (iqs >= 0)
 querystring = (iqs < currurl.Length - 1) ? currurl.Substring(iqs + 1) : String.Empty;

 // Parse the query string variables into a NameValueCollection.
 NameValueCollection qscoll = HttpUtility.ParseQueryString(querystring);

 // Iterate through the collection.
 StringBuilder sb = new StringBuilder();
 foreach (String s in qscoll.AllKeys)
 sb.Append(s + " - " + qscoll[s] + "<br />");

 // Write the results to the appropriate labels.
 ParseOutput.Text = sb.ToString();
 UrlRawOutput.Text = currurl;
 UrlEncodedOutput.Text = HttpUtility.UrlEncode(currurl);
 UrlDecodedOutput.Text = HttpUtility.UrlDecode(currurl);


se alguém puder me ajudar.
if someone can help me. [Google Translate]

[edit]Just the Portuguese to English - OriginalGriff[/edit]
Updated 30-Jun-11 21:48pm
Prerak Patel 1-Jul-11 3:11am
What is the problem?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Your question is not too clear. Though it sounds like you have issues with using Querystring.

For details of how to pass and use query strings, look here:
Passing variables between pages using QueryString[^]
Another link describing the same[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100