|
for example, an online user wants to retrieve data from a remote server database, after entering the search creteria (e.g. keyword),then click "Search" button, later on, the UI will be refreshed and the data will be displayed, in this case, it seems it is because the remote server triggers the updates to the client UI after getting data from database,
in which way does the server update the client UI (by something like HttpResponse...?
So what I want is an online client stops a running service which is running on the remote server, after clicking on the "StopService" button, he just sits back, and the backend logic will implement the service stopping process, and once it is done successfully, the service status in client UI will be updated to be "Stopped", can the server do that through some mechanisms? I don't want the user to manually click the "Refresh" button to get the latest
service status or I don't want to put the timer on the client side to periodically query the remote server
continue with the above question, what if I have 2 running services and the client clicks on the "Stop All" button, suppose each of the two services take some time to be stopped. May the UI get automatically updated once service1 is stopped successfull (service1 status will be "Stopped" while service2 status is still "Running") and Once service2 gets stopped successfully, the UI will be updated again to reflect the latest service2 status?
Does synchronous or asynchronous Service stopping affect the UI updating in this case?
Pleae help. Thank you.
|
|
|
You've already asked this same basic question in another thread. The web is a stateless environment. It's based upon a request/response methodology. You can't get a response without first making a request. This means that the server cannot "push" updates to the client. The client must request them.
If you want to get status updates, one way is to use a timer in your JavaScript. It can do a request to the server every few seconds, and return the status.
|
|
|
|
|
But how do you explain the example I have given ..."for example, an online user wants to retrieve data from a remote server database, after entering the search creteria (e.g. keyword) on the UI,then click "Search" button, the user just sits back, later on, the UI will be refreshed and the table of data will be displayed".
This is a common application case which you may see everywhere, do you think it has a timer defined?
|
|
|
"an online user wants to retrieve data from a remote server database"
Request: search page
Response: search page
"after entering the search creteria (e.g. keyword) on the UI,then click "Search" button"
Request: search page submitted
"the user just sits back, later on, the UI will be refreshed and the table of data will be displayed"
Response: new page with data
Request - Response. Nothing magical happening here.
What would be magic is: "user clicks Search, and the UI is updated every 5 records found to display a running total". That would be a single Request with an indefinite number of Responses.
|
|
|
|
|
|
|
You would use WMI to interact with system services. It doesn't solve your request/response difficulty. In fact, that article states:
"You would use the refresh meta tag as in this classic ASP sample that uses WMI directly. "
The "refresh meta tag" is a way to force the browser to issue another request to the server (initiating of course another response). It's functionally equivalent to a timer.
|
|
|
|
|
I've been thinking about this. This comes up so often, and it's something that so many people want.
Then *only* approach I think has a chance is to never end the response from the server, until the final task is complete.
In other words, don't use a timer on the client, use a timer on the SERVER. Import the System.Timer namespace as use the timer object. Every so often, when the "OnTimerElapsed" (going from memory, that might not be correct) event fires, check the status of your other operation, and do a Response.Flush(). Then when it completes, do a Response.End().
Problems with this:
1) It holds open the server/browser connection. Horrible for performance.
2) It doesn't work. You cannot control when or if a browser will display/render its buffer. Flushing things out doesn't mean the browser will immediately render it. Is that always true? Worth exploring. Maybe writing out scripts?
Are there other methods in ASP.NET we can use. Can we for example, overload the Render() method to assist us?
I'll be exploring these issues. If I come up with something that will work, I'll let you know.
|
|
|
|
|
as you said "What would be magic is: "user clicks Search, and the UI is updated every 5 records found to display a running total". That would be a single Request with an indefinite number of Responses.", so from my understanding, you mean for all these similar applications, it basically ALWAYS does a REFRESH from the client side (by defining a timer or scripting..etc).
My boss just doesn't believe this no matter how I explain the fact to him. is there any online article/application with code to be the evidence?
Really thanks!
|
|
|
You can tell him I said so. I'm an expert. It even says so, just look to the right. I've been doing web development since there was a web. Before that I did "online system" programming, on CompuServe and BBSes.
The entire nature of the web is Request/Response. That's it. Period.
It's even built-in to the terminology. The browser generates "request headers", and the server has "response headers".
I honestly don't know where you would find a document that your boss would consider authoritative about something so basic.
Maybe this: http://www.cs.wpi.edu/~frontier/e03/lab01/clientServer.html.
He's wrong, we're right.
<Added>
Also, many web-based applications that display "loading" or "please wait" status messages or progress bars are simply displaying an animated gif. All the "action" or "progress" is on the client. In many cases, the graphic is already there, and as soon as you "submit" the request, the client makes it visible while it waits for the server.
Another link: http://www.io.com/~maus/HttpKeepAlive.html
|
|
|
|
|
I appreciate so much for you kind help!!! billions of thanks. Finally confirm with you something
When the user types the URL, he will be two services in "Running" status. Now, he clicks on the "StopAll Button",
the code is similar as :
public void btnStopAll.click(Object sender, System.EventArgs e){
ArrayList seriveStatusList = new ArrayList();
//call remote server function, which takes 10 seconds
//serviceNameList contains the two serivces names for the server to identify which service to stop
RemoteServer.stopservices(serviceNameList);
//Processing done, collect the new status data
serviceStatusList.add(getService1Status(serviceName));
serviceStatusList.add(getService2Status(serviceName));
DataGrid1.DataSource = serviceStatusList;
DataGrid1.bind();
}
---------------------
Now I have obtained the latest the status data and rebind it to the datagrid.
but the UI won't be updated, right?
in the Global.aspx.cs file, there are "Application_Start(); Session_Start(); Application_BeginRequest....." don't know whether it helps?
|
|
|
The UI will be updated.
You REQUEST a Page. That Page contains a DataGrid and a Stop button. The server RESPONDS by sending you that page.
Then the server promptly forgets everything.
You click the stop button. The browser sends a REQUEST to the server, which runs that code you posted. When it's done, the server sends a RESPONSE back to the browser, which contains your "new" datagrid.
|
|
|
|
|
Thank u so much for your kind help! yes, you r right, the UI will be updated. Another case:
Say I am making a synchronous call;
On the client side, I have the code:
public void btnStopService.click(Object sender, System.EventArgs e){
ArrayList seriveStatusList = new ArrayList();
//call remote server function synchronously, which takes time to finish
RemoteServer.StopServices(serviceName);
serviceStatusList.add(getService1Status(serviceName));
serviceStatusList.add(getService2Status(serviceName));
DataGrid1.DataSource = serviceStatusList;
DataGrid1.bind();
}
and at the backend , I execute
void StopServices(ArrayList serviceNameList){
try{
foreach (string serviceName in serviceNameList){
ServiceController svc = new ServiceController(serviceName);
svc.Stop();
svc.WaitForStatus(ServiceControllerStatus.Stopped);
}
}
catch (Exception){
}
My Questions are:
(1) in the above case, if the service stopping takes long time, will the web request time-out? if so, that means
the data rebinding at the client side won't be executed? right?
(2) I am using svc.WaitForStatus(ServiceControllerStatus.Stopped); (no time out defined here, coz I don't know how
long the service takes to stop...), I think there is a possibility that the code will be blocked forever here,
right? just waiting , waiting for the "Stopped" status..How can I avoid this?
(3) In terms of excepion, what kinds of exceptions may occur when controlling a service, what I can think of is "
access right exception", what else?
Thank you!!!
|
|
|
I'm not familiar with stopping/starting services with ASP.NET, so can't address some of your specific questions on the topic.
It is possible for the browser to time out, yes.
That's why my original suggestion: user clicks "stop", the server
1) immediately generates a response. The user will see a "service is stopping, click here to see status" page.
2) the server then initiates another thread (or even executes a separate program) to stop the service.
When the user clicks "update status", they will get the current status returned.
Have you heard of the "drowning man" syndrome? That's when someone swims out to help a drowning swimmer, and gets pulled down by them. I'm feeling a bit like that. I'm happy to help you with general questions, but we're getting into areas that you'll have to solve yourself. I wish you well with your project!
|
|
|
|
|
:):), sure, understand. Appreciate your help so much. Merry Christmas!!
|
|
|
Thank you! Thanks for understanding.
|
|
|
|
|
|
|
|
|
|