Click here to Skip to main content
11,577,710 members (42,750 online)
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 15-May-12 23:16pm
Edited 16-May-12 11:28am
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 DamithSL 180
1 Peter Leow 180
2 Richard MacCutchan 125
3 Abhinav S 125
4 OriginalGriff 115
0 OriginalGriff 820
1 Sergey Alexandrovich Kryukov 681
2 Abhinav S 528
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 375


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 16 May 2012
Copyright © CodeProject, 1999-2015
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