C# .NET - querystring?????

Asked By srikanth panneer selvam on 19-Sep-08 02:08 AM

hi i have page1 and page2 in asp.net + c#...


in page1 i am displaying gridview details.. whcih shows number of records..

by selecting anyone it will go foir page2 for approval.. when we approve that one in page 2,

it should come back with querystring like this (

Response.Redirect("~/Modules/HRMS/SbuAdmin.aspx?Confirm=ok" );

) for page1 and here the querystring should be validated in page load ..

untill this it works nice.

but

after validating i want to clear the querystring for the further operations.. but it is not done..

please help me for clearing the querystring oir passing some other value in the querystring because whenever i click any buttons or check boxes it shows validates the querystring again and again..

its urgent


Remove Querystring

Shailendrasinh Parmar replied to srikanth panneer selvam on 19-Sep-08 02:16 AM

Have you looked at the HttpContext.Items collection? This could be an elegant alternative. Another approach could be to use a session variable that is set prior to the return to the original page.

OR

I would suggest not using querystring if you are transferring info from one page to another. why dont you use server.transfer.
That way your order id information is not visible.

Or you can try the following code ::

After processing in Page_Load event do this to remove Query String

Me.RegisterClientScriptBlock("Temp", "<script language=JavaScript>parent.frames('mainFrame').document.forms('Form1').action='<Page Name';</script>")

you will not get this method in Intellisense

Also see the following article :: http://forums.asp.net/t/321365.aspx

Hope it helps.

Remove Querystring

Shailendrasinh Parmar replied to srikanth panneer selvam on 19-Sep-08 02:17 AM

See this msdn help article if it helps you

http://support.microsoft.com/kb/810218

All the best.

solution

Perry replied to srikanth panneer selvam on 19-Sep-08 04:21 AM

Use dynamically generated SOAP request

<?xml version='1.0' encoding='UTF-8'?>
<!-- Note that the Body contents could be any valid SOAP request -->
<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'>
<Body>
<find_business generic='1.0' xmlns='urn:uddi-org:api'>
<name>Microsoft</name>
</find_business>
</Body>
</Envelope>

You can save this to your web folder as "uddi.xml".

Now let's construct the ASPX page that will receive the querystring parameters, send out the request, and return the result:

<% @ Page Language="C#" %>
<% @Import Namespace="System" %>
<% @Import Namespace="System.Xml" %>
<% @Import Namespace="System.Text" %>
<% @Import Namespace="System.IO" %>
<% @Import Namespace="System.Net" %>

<script Language="C#" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
string xmlfile;
xmlfile=Request.Params["xmlfile"];
if (xmlfile==null)
xmlfile="uddi.xml";
HttpSOAPRequest(xmlfile,null);
}

void HttpSOAPRequest(String xmlfile, string proxy)
{
XmlDocument doc = new XmlDocument();
doc.Load(@"C:\Inetpub\wwwroot\ASP.NET\" +xmlfile);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://uddi.microsoft.com/inquire");
if (proxy != null) req.Proxy = new WebProxy(proxy,true);
// if SOAPAction header is required, add it here...
req.Headers.Add("SOAPAction","\"\"");

req.ContentType = "text/xml;charset=\"utf-8\"";
req.Accept = "text/xml";
req.Method = "POST";
Stream stm = req.GetRequestStream();
doc.Save(stm);
stm.Close();
WebResponse resp = req.GetResponse();
stm = resp.GetResponseStream();
StreamReader r = new StreamReader(stm);
// process SOAP return doc here. For now, we'll just send the XML out to the browser ...
Response.Write(r.ReadToEnd());
}
</script>

http://www.eggheadcafe.com/articles/20011103.asp

-Paresh