Multiple gets from a page

  • Thread starter Thread starter Clint
  • Start date Start date
C

Clint

Is such a scenario possible?

I have a page, which has 1 text box & 2 buttons.

When Button1 is clicked, it submits a GET to the server.
The server doesn't send a response to this get immediatelly, the
server is waiting for some other event to occur (not from the client,
but in it's own surrounding) before it responds.
Now when this is happening, if the user clicks on the 2nd button,
I want to send the text in the text box to the server through a 2nd
GET (served by a different asp page).

When I try this - my Page_load for the
2nd page doesn't get called at all?
Is such a thing possible at all? If not, any other change
I can make to my design to simulate this?
 
Clint said:
Is such a scenario possible?

I have a page, which has 1 text box & 2 buttons.

When Button1 is clicked, it submits a GET to the server.
The server doesn't send a response to this get immediatelly, the
server is waiting for some other event to occur (not from the client,
but in it's own surrounding) before it responds.
Now when this is happening, if the user clicks on the 2nd button,
I want to send the text in the text box to the server through a 2nd
GET (served by a different asp page).

When I try this - my Page_load for the
2nd page doesn't get called at all?
Is such a thing possible at all? If not, any other change
I can make to my design to simulate this?

Just to clarify, I am using the built-in webserver with VS to try this
out.
 
And do what once the text is sent ? You could likely use an AJAX like
solution (try http://www.w3schools.com/dom/dom_http.asp).

Depending on what exactly you are trying to do another option could be also
to submit the data to always the same page and have your web page then use
System.Net.WebClient to submit these data to a third party site (if this is
what you are after).
 
Patrice said:
And do what once the text is sent ?

Once the text is sent the server will do some action based on it &
send a response.
You could likely use an AJAX like
solution (try http://www.w3schools.com/dom/dom_http.asp).

Depending on what exactly you are trying to do another option could
be also to submit the data to always the same page

My main issue is that I am sending 2 GETS, the 2nd GET being sent
when a response hasn't yet been sent by the server for the first GET.

I am not able to do it successfully.
and have your web
page then use System.Net.WebClient to submit these data to a third
party site (if this is what you are after).

No - I am not sending it to a 3rd party site.
 
Clint said:
When Button1 is clicked, it submits a GET to the server.
The server doesn't send a response to this get immediatelly, the
server is waiting for some other event to occur (not from the client,
but in it's own surrounding) before it responds.
Now when this is happening, if the user clicks on the 2nd button,
I want to send the text in the text box to the server through a 2nd
GET (served by a different asp page).
Is such a thing possible at all? If not, any other change
I can make to my design to simulate this?

Depending on what it is you want to do you might get a good result from
using AJAX.
 
Have you checked the IIS log ? For now I would say that you just post the
same page (this is the default behavior for ASP.NET, have you done something
to change this ?)

Before further investigation you may want to explain this group what you are
trying to do in a non technical way. The web is based on request/response
pairs. What should do the first response if you issue a second GET ?

Knowing exactly what is the overall goal, someone will perhaps suggest
another technical solution than the one you are currently investigating (the
first button could be an out of band request à la AJAX and the second one be
the real submit ?)
 
Henrik said:
Depending on what it is you want to do you might get a good result
from using AJAX.

I am already using AJAX - the GETs I was talking about is something
like this

xmlHttp = GetXmlHttpObject(processResponse); // Hook a callback to the
response
xmlHttp.open("GET",url,true);
and then send.


This is the problem I am having.

My browser client does 2 things.
One of the GETs it sends is something for which the server can send a
response immediatelly.
- for eg. if the user clicks on a button "getinfoX" - it calls the server to
getinfoX which the
server returns immediatelly.

- The other GET is used in the following way - send a request to server
"send me a response
when some event happens at the server" i.e. when I send this GET the server
has no response to send immediately - but as and when the event happens,
the server uses this GET to inform the other clients about this. I don't
want to
use polling here & hence I want to send a GET to server which can be left
hanging around in the server to use for this notification.

To achieve this I have 2 frames on my client - one hidden & one regular.
One of them sends the regular GET as a result of user clicking the button
& the other sends the pending GET.

On the server, I have 2 pages, both derived from System.web.ui.Page.
I do the processing on Page_load in both the pages.

In the first one I have
protected void Page_Load() {
// stuff
Response.Write(something)

}
In the 2nd GET aspx - I have to have a loop like this.

protected void Page_Load() {
// stuff

while(true) {
if(HasEventHappened()) {
Response.Write(something);
break;
}
Thread.Sleep(sometime);

}


}


Now, because of this while loop, the server never gets the other GET at
all - i.e.
it seems to be stuck in this while loop & hence is not able to process the
other
GET.

I am total newbie with Web programming - so forgive me if my question is
totally
stupid.

Is my design totally wrong?
Is there a better way to achive what I want - i.e. the ability for a client
to
recieve 2 kinds of responses - one synchronous & the other asynchronous.
 
Patrice said:
Have you checked the IIS log ? For now I would say that you just post
the same page (this is the default behavior for ASP.NET, have you
done something to change this ?)

Before further investigation you may want to explain this group what
you are trying to do in a non technical way. The web is based on
request/response pairs. What should do the first response if you
issue a second GET ?

I have explained this in another post - my reply to Henrik
Knowing exactly what is the overall goal, someone will perhaps suggest
another technical solution than the one you are currently
investigating (the first button could be an out of band request à la
AJAX and the second one be the real submit ?)

What exactly is an out of band request - how is it done?
 
Clint skrev:
Is my design totally wrong?
Is there a better way to achive what I want - i.e. the ability for a client
to
recieve 2 kinds of responses - one synchronous & the other asynchronous.

I don´t know how to do it "manually", but the free AJAX.NET
(www.ajaxpro.net) AJAX library lets you define callback functions. This
is exactly what you want - call the serverside function and have it
call a clientside function when its done.

The backside of this is that Internet Explorer only allows you to have
2 connections waiting for response at any time - so if you have 2 of
them waiting, any other request to you site will be queued until 1 of
your active connections finishes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top