Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# query url webbrowser
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 16-May-12 0:16am
Edited 16-May-12 12:28pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try Request.Querystring to extract those values
 
Here is a sample[^]
 
Regards
Sebastian
  Permalink  
v2
Comments
Ugur Inanc at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

you can try this:
 
string value=Request.QueryString["OWASP_CSRFTOKEN"];
  Permalink  
v2
Comments
Ugur Inanc at 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.
Ajayreddy2611 at 16-May-12 5:33am
   
u need to create object of that page after that u can try through that object.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Add a handler for 'Navigated' event:
 
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:
webBrowser1.Document.Url.Query
but you'll have to make sure the browser finished loading the document.
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

you can try this one also:
 
string strval=Request.QueryString[0];
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 315
1 Jochen Arndt 190
2 DamithSL 125
3 PIEBALDconsult 110
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 16 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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