Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Using C# I'm using a 'webbrowser' to navigate to particular URLs.
However, when I clicked on a certain button on the browser, a new page is opened and I need to get the session id (in other words, the part after the question mark) of this page.

The URL of the new page is below.
www.fbwebpos.com/finans/report/transaction.search?<b>OWASP_CSRFTOKEN=ZSOT-CPUM-N32D[^]

webBrowser.Url.ToString() only returns: www.fbwebpos.com/finans/report/transaction.search[^]

webBrowser1.Url.Query.ToString() returns empty.

Thank you.
Posted
Updated 16-May-12 11:28am
v2

try Request.Querystring to extract those values

Here is a sample[^]

Regards
Sebastian
 
Share this answer
 
v2
Comments
Ugur Inanc 16-May-12 5:25am    
Thanks for your answer. However, I'm working on a windows form application and if I'm not mistaken your suggestion is valid for web projects.
you can try this:

string value=Request.QueryString["OWASP_CSRFTOKEN"];
 
Share this answer
 
v2
Comments
Ugur Inanc 16-May-12 5:29am    
Thanks but how can i make use of request.querystring in a windows form applicaiton. It gives error when I tried to apply this solution to my project.
MAKReddy 16-May-12 5:33am    
u need to create object of that page after that u can try through that object.
Add a handler for 'Navigated' event:

C#
private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
    string query = e.Url.Query;
}


This will give you query string part of URL including the question mark at start.

Alternatively you can use:
C#
webBrowser1.Document.Url.Query

but you'll have to make sure the browser finished loading the document.
 
Share this answer
 
v3
you can try this one also:

string strval=Request.QueryString[0];
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900