473,408 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Fooling Website into thinking Im a browser

Hi All,

I am trying to make a few calls in succession to a website to allow me to
login and then perform a search, in a c# windows program.

wcResponse =
wc.UploadData("http://www.website.com/login?service2&user=joebloggs&blah","P
OST", new byte[]{});

wcResponse =
wc.UploadData("http://www.website.com/login?service3&search="+search_string,
"POST", new byte[]{});
However when using WebClient there is no concept of any session state
between calls that would let the website think I am logged in by the time I
get to call 2. Bear in mind call2 can not be done at the same time as call
1. You see by the time I get to call 2 the website thinks I'm not logged in.
e.t.c.
Is there anyway of doing this?

Cheers

Alan


Nov 15 '05 #1
6 1298
Move your ResponseHeaders into your Headers. They are passing you some cookies
most likely
and you need to store these across calls. Use the sample program under
ResponseHeaders property
to investigate the headers associated with the response to make sure the proper
cookies are being sent back.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Alan" <a.*************@locland.com> wrote in message
news:Oa**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I am trying to make a few calls in succession to a website to allow me to
login and then perform a search, in a c# windows program.

wcResponse =
wc.UploadData("http://www.website.com/login?service2&user=joebloggs&blah","P
OST", new byte[]{});

wcResponse =
wc.UploadData("http://www.website.com/login?service3&search="+search_string,
"POST", new byte[]{});
However when using WebClient there is no concept of any session state
between calls that would let the website think I am logged in by the time I
get to call 2. Bear in mind call2 can not be done at the same time as call
1. You see by the time I get to call 2 the website thinks I'm not logged in.
e.t.c.
Is there anyway of doing this?

Cheers

Alan

Nov 15 '05 #2
Hi Thanks for your quick reply.

I tried what you said and in between calls :

wc.UploadData(....);
wc.Headers = wc.ResponseHeaders;
wc.UploadData(...);

and it just gives me an exception when I run it. Is it possible I should
only be copying the keys that are relevant. That is the session keys?
Cheers

Alan
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
Move your ResponseHeaders into your Headers. They are passing you some cookies most likely
and you need to store these across calls. Use the sample program under
ResponseHeaders property
to investigate the headers associated with the response to make sure the proper cookies are being sent back.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Alan" <a.*************@locland.com> wrote in message
news:Oa**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I am trying to make a few calls in succession to a website to allow me to login and then perform a search, in a c# windows program.

wcResponse =
wc.UploadData("http://www.website.com/login?service2&user=joebloggs&blah","P OST", new byte[]{});

wcResponse =
wc.UploadData("http://www.website.com/login?service3&search="+search_string, "POST", new byte[]{});
However when using WebClient there is no concept of any session state
between calls that would let the website think I am logged in by the time I get to call 2. Bear in mind call2 can not be done at the same time as call 1. You see by the time I get to call 2 the website thinks I'm not logged in. e.t.c.
Is there anyway of doing this?

Cheers

Alan


Nov 15 '05 #3
You should be only copying cookie headers. Headers and ResponseHeaders are both
full fledged WebHeadersCollection objects, so you'll need to use the appropriate
methods
to operate on them.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Alan" <a.*************@locland.com> wrote in message
news:Ov**************@TK2MSFTNGP12.phx.gbl...
Hi Thanks for your quick reply.

I tried what you said and in between calls :

wc.UploadData(....);
wc.Headers = wc.ResponseHeaders;
wc.UploadData(...);

and it just gives me an exception when I run it. Is it possible I should
only be copying the keys that are relevant. That is the session keys?
Cheers

Alan
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
Move your ResponseHeaders into your Headers. They are passing you some

cookies
most likely
and you need to store these across calls. Use the sample program under
ResponseHeaders property
to investigate the headers associated with the response to make sure the

proper
cookies are being sent back.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Alan" <a.*************@locland.com> wrote in message
news:Oa**************@TK2MSFTNGP12.phx.gbl...
Hi All,

I am trying to make a few calls in succession to a website to allow me to login and then perform a search, in a c# windows program.

wcResponse =
wc.UploadData("http://www.website.com/login?service2&user=joebloggs&blah","P OST", new byte[]{});

wcResponse =
wc.UploadData("http://www.website.com/login?service3&search="+search_string, "POST", new byte[]{});
However when using WebClient there is no concept of any session state
between calls that would let the website think I am logged in by the time I get to call 2. Bear in mind call2 can not be done at the same time as call 1. You see by the time I get to call 2 the website thinks I'm not logged in. e.t.c.
Is there anyway of doing this?

Cheers

Alan



Nov 15 '05 #4
Hi,

I tried that and it doesn't seem to work. Is there any other way of doing
this using different classes. I got it to work using XML from a browser in
ASP but obviously the browser retains the header collection in some way that
works?

Thanks again

Alan
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:ej**************@TK2MSFTNGP12.phx.gbl...
You should be only copying cookie headers. Headers and ResponseHeaders are both full fledged WebHeadersCollection objects, so you'll need to use the appropriate methods
to operate on them.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Alan" <a.*************@locland.com> wrote in message
news:Ov**************@TK2MSFTNGP12.phx.gbl...
Hi Thanks for your quick reply.

I tried what you said and in between calls :

wc.UploadData(....);
wc.Headers = wc.ResponseHeaders;
wc.UploadData(...);

and it just gives me an exception when I run it. Is it possible I should
only be copying the keys that are relevant. That is the session keys?
Cheers

Alan
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
Move your ResponseHeaders into your Headers. They are passing you some
cookies
most likely
and you need to store these across calls. Use the sample program under
ResponseHeaders property
to investigate the headers associated with the response to make sure
the
proper
cookies are being sent back.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Alan" <a.*************@locland.com> wrote in message
news:Oa**************@TK2MSFTNGP12.phx.gbl...
> Hi All,
>
> I am trying to make a few calls in succession to a website to allow
me to
> login and then perform a search, in a c# windows program.
>
> wcResponse =
>

wc.UploadData("http://www.website.com/login?service2&user=joebloggs&blah","P > OST", new byte[]{});
>
> wcResponse =
>

wc.UploadData("http://www.website.com/login?service3&search="+search_string,
> "POST", new byte[]{});
>
>
> However when using WebClient there is no concept of any session state > between calls that would let the website think I am logged in by the

time I
> get to call 2. Bear in mind call2 can not be done at the same time

as call
> 1. You see by the time I get to call 2 the website thinks I'm not
logged in.
> e.t.c.
>
>
> Is there anyway of doing this?
>
> Cheers
>
> Alan
>
>
>
>



Nov 15 '05 #5
You can use WebRequest with a CookieContainer attached. The CookieContainer
will hold and parse your return cookies.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Alan" <a.*************@locland.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...
Hi,

I tried that and it doesn't seem to work. Is there any other way of doing
this using different classes. I got it to work using XML from a browser in
ASP but obviously the browser retains the header collection in some way that
works?

Thanks again

Alan
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:ej**************@TK2MSFTNGP12.phx.gbl...
You should be only copying cookie headers. Headers and ResponseHeaders

are both
full fledged WebHeadersCollection objects, so you'll need to use the

appropriate
methods
to operate on them.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Alan" <a.*************@locland.com> wrote in message
news:Ov**************@TK2MSFTNGP12.phx.gbl...
Hi Thanks for your quick reply.

I tried what you said and in between calls :

wc.UploadData(....);
wc.Headers = wc.ResponseHeaders;
wc.UploadData(...);

and it just gives me an exception when I run it. Is it possible I should
only be copying the keys that are relevant. That is the session keys?
Cheers

Alan
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
> Move your ResponseHeaders into your Headers. They are passing you some cookies
> most likely
> and you need to store these across calls. Use the sample program under
> ResponseHeaders property
> to investigate the headers associated with the response to make sure the proper
> cookies are being sent back.
>
>
> --
> Justin Rogers
> DigiTec Web Consultants, LLC.
> Blog: http://weblogs.asp.net/justin_rogers
>
> "Alan" <a.*************@locland.com> wrote in message
> news:Oa**************@TK2MSFTNGP12.phx.gbl...
> > Hi All,
> >
> > I am trying to make a few calls in succession to a website to allow me to
> > login and then perform a search, in a c# windows program.
> >
> > wcResponse =
> >
wc.UploadData("http://www.website.com/login?service2&user=joebloggs&blah","P > > OST", new byte[]{});
> >
> > wcResponse =
> >
wc.UploadData("http://www.website.com/login?service3&search="+search_string, > > "POST", new byte[]{});
> >
> >
> > However when using WebClient there is no concept of any session state > > between calls that would let the website think I am logged in by the
time I
> > get to call 2. Bear in mind call2 can not be done at the same time as call
> > 1. You see by the time I get to call 2 the website thinks I'm not logged in.
> > e.t.c.
> >
> >
> > Is there anyway of doing this?
> >
> > Cheers
> >
> > Alan
> >
> >
> >
> >
>
>



Nov 15 '05 #6
Thanks Justin I have now resolved the problem by doing it the original way
you specified. I wasn't setting the format of the cookies correctly.

Thanks for all your help.
Cheers

Alan
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:ON**************@tk2msftngp13.phx.gbl...
You can use WebRequest with a CookieContainer attached. The CookieContainer will hold and parse your return cookies.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Alan" <a.*************@locland.com> wrote in message
news:O2**************@TK2MSFTNGP09.phx.gbl...
Hi,

I tried that and it doesn't seem to work. Is there any other way of doing
this using different classes. I got it to work using XML from a browser in ASP but obviously the browser retains the header collection in some way that works?

Thanks again

Alan
"Justin Rogers" <Ju****@games4dotnet.com> wrote in message
news:ej**************@TK2MSFTNGP12.phx.gbl...
You should be only copying cookie headers. Headers and ResponseHeaders
are both
full fledged WebHeadersCollection objects, so you'll need to use the

appropriate
methods
to operate on them.

--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers

"Alan" <a.*************@locland.com> wrote in message
news:Ov**************@TK2MSFTNGP12.phx.gbl...
> Hi Thanks for your quick reply.
>
> I tried what you said and in between calls :
>
> wc.UploadData(....);
> wc.Headers = wc.ResponseHeaders;
> wc.UploadData(...);
>
> and it just gives me an exception when I run it. Is it possible I
should > only be copying the keys that are relevant. That is the session keys? >
>
> Cheers
>
> Alan
>
>
> "Justin Rogers" <Ju****@games4dotnet.com> wrote in message
> news:OY**************@TK2MSFTNGP09.phx.gbl...
> > Move your ResponseHeaders into your Headers. They are passing you

some
> cookies
> > most likely
> > and you need to store these across calls. Use the sample program under > > ResponseHeaders property
> > to investigate the headers associated with the response to make sure the
> proper
> > cookies are being sent back.
> >
> >
> > --
> > Justin Rogers
> > DigiTec Web Consultants, LLC.
> > Blog: http://weblogs.asp.net/justin_rogers
> >
> > "Alan" <a.*************@locland.com> wrote in message
> > news:Oa**************@TK2MSFTNGP12.phx.gbl...
> > > Hi All,
> > >
> > > I am trying to make a few calls in succession to a website to
allow me
> to
> > > login and then perform a search, in a c# windows program.
> > >
> > > wcResponse =
> > >
>

wc.UploadData("http://www.website.com/login?service2&user=joebloggs&blah","P > > > OST", new byte[]{});
> > >
> > > wcResponse =
> > >
>

wc.UploadData("http://www.website.com/login?service3&search="+search_string,
> > > "POST", new byte[]{});
> > >
> > >
> > > However when using WebClient there is no concept of any session

state
> > > between calls that would let the website think I am logged in by the > time I
> > > get to call 2. Bear in mind call2 can not be done at the same

time as
> call
> > > 1. You see by the time I get to call 2 the website thinks I'm
not logged
> in.
> > > e.t.c.
> > >
> > >
> > > Is there anyway of doing this?
> > >
> > > Cheers
> > >
> > > Alan
> > >
> > >
> > >
> > >
> >
> >
>
>



Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Bozo Schmozo | last post by:
Greetings! I've searched groups.google.com already to see if I can determine if using PHP/MySQL (if needed) for a web site I wish to develop. As the subject indicated, it will be a content...
11
by: Ike | last post by:
I changing the size of frames dynamically in a page (I am restricted in that I cannot perform a reload of the content of any of the frames). In MSIE, when I resize the frames, thinks repaint...
4
by: Kim André Akerø | last post by:
I'm currently revamping my personal website, and I need some opinions: http://www.neonnero.com/nn2preview/ None of the links on the right-hand navigation menu work yet, so don't bother. This is...
20
by: Mike Barnard | last post by:
Hi. When looking at a website I can use VIEW / SOURCE to see the HTML, but any external .css files don't show up. Is there a way to see them and see what someone has done to get an effect? ...
2
by: laredotornado | last post by:
Hi, Is it possible to fool Javascript running on a Mac Safari web browser into believing it is a PC IE browser? We have the following JS code that is detecting both Mac and Safari. Sadly, we do...
13
by: Kobee | last post by:
Hi, I'm having a few issues adapting to new 2.0 "website" project vs. the old 1.1 "web application". One of the major issues I'm having is with the notion of namespaces. Using the old way, I...
2
by: crferguson | last post by:
I'm having a really odd issue. Recently my company has upgraded our data server. For a couple of months I'm having to host two versions of the same website on our webserver until the new data...
6
by: junkmate | last post by:
I have made an RSS reader and am testing on the BBC website, and I use this code to grab the contents of the XML file, however when I look at the contents grabbed by my function, and the HTML...
12
by: Jonathan Wood | last post by:
Greetings, I wonder if anyone can help me with this. I have an XP laptop, and a Vista desktop computer. I use the laptop to run software remotely on the desktop using the Remote Desktop...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.