This is a migrated thread and some comments may be shown as answers.

Ajax Design Question

3 Answers 51 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 05 Aug 2009, 09:08 PM
I have a scenario and I'm struggling with the best way to implement it using Rad Ajax controls.

The system I have has a very custom single sign on process with multiple redirects and code execution. Here is the current flow:

1. Enter info, click Login button
2. Redirect to Site 2
3. Site 2 does it's thing (outside of my control)
4. Site 2 redirects back to Page 2 on Site 1
5. Page 2 does all sorts of processing, multiple web service calls to multiple sites
6. Upon completion, Redirect to Site 3
7. Site 3 does its thing (I have control of this site and on same server as Site 1)
8. Site 3 redirects back to Site 1
9. Done

This whole process takes anywhere from 5-35 seconds on different computers, connections, etc. So I'm trying to figure out a way to give the user a better experience. Currently, the browser does not display any other pages other than Page 1 on Site 1. All of the other redirects and pages listed above are simply blank pages with code behind. So the user doesn't even know they are being redirected multiple times.

I'm almost 99% sure I can't do anything with Ajax when it involves redirects...? If that assumption is correct, my only option is to do something with Step 5 above. Since Page 2 on Site 1 does all the code processing, web service calls, etc. I am thinking I can Ajax that page. Currently all the code for that page simply executes on page load, then redirects.

How can I put an Ajax Loading Panel on the page and get it to fire on Page_Load, have all the code execute, and then redirect when finished? My initial thought is to put a timer on Page_Load that will basically pause things for a split second, once the timer completes it would fire off the function that handles the code execution (and the Loading Panel display), once the code execution completes it would redirect as normal.

I'm looking for the best implementation here, so even if I'm way off base, I'd appreciate any ideas. Thanks.

3 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 10 Aug 2009, 02:12 PM
Hi Joe,

A complicated scenario indeed. A few things I can note.

If you are using Response.Redirect (or an alternative) that directly redirects the browser request to another web site, you can do pretty much nothing with AJAX or any other architecture, simply because the browser will constantly be loading pages around.

If, on the other hand, you use your first web site's code-behind to request your web sites remotely, pass them arguments, get their returned data and thus initiate server cross-site request on the first page's code-behind, you can, at this time, display an AJAX loading panel to indicate the server is working. But you will notice that this introduces a totally different scheme of cross-site interaction, and you may not, as you mentioned, have control over all of your sites.

A third approach you started talking about is display some kind of a loading panel on every site. In your current approach this option is also not possible. The reason for this is that the web site never renders anything back to the response stream itself. As all processing is done in code-behind before the response is rendered, nothing is actually rendered to the browser before the page redirects to the next web site in the queue. Is it clear or should I explain better?

The last approach mentioned can be simulated by first loading some kind of process indicator page and setting a timer to fire a postback event after the page has loaded. Thus, in your timer's Tick event, you can start your long and expensive processing, while the user will still have some visual while waiting.

If anything is unclear, let me know.

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Joe
Top achievements
Rank 1
answered on 10 Aug 2009, 06:51 PM
Veli,

Thank you for the very thought out response. That is almost exactly what I had in mind and confirmed most of my assumptions. The cross-site requests is a new idea for me, and I think I'll pursue that with the 3rd party vendors that control the other sites.

It seems the approach with the timer is my only real option at this point, just a follow up on that. Is there any performance concerns at all with this approach? Also, is there any limitations on the timer tick event? Since I'm going to be starting that on page load, I would love to set the tick event to a very small number, possibly milliseconds, so that the processing starts right away, and obviously when processing ends, I would stop the timer and redirect. Is there anything I need to worry about with that? I'm thinking the .NET page lifecycle, I don't want to get in the way of any other normal processing that may need to happen or somehow lock up the browser by initiating that too quickly.

Thanks again,
Joe
0
Veli
Telerik team
answered on 11 Aug 2009, 11:16 AM
Hi Joe,

You are in the correct way of thoughts. I believe you can successfully set the timer interval to a very small value. You should be able to even do this without a timer, straight from the javascript pageLoad event (with ASP.NET AJAX framework), or from window.onload. Let me know if you need an example with Telerik AJAX controls, we can provide you a small mock up project. Particularly, you can place a RadAjaxManager on page, and use its client-side API to call the ajaxRequest method with a custom server. Back on the server, this fires the server-side AjaxRequest event of the control, inside which, your expensive compuations may start.

The server-side processing should also be done without any issues. Regardless, of whether you use RadAjaxManager, Timer or both, the postback (or AJAX callback in this case) occurs in the context of a full page lifecycle. Therefore, there should not be any erroneous conditions away from the regular postback appraoch.

All the best,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Joe
Top achievements
Rank 1
Answers by
Veli
Telerik team
Joe
Top achievements
Rank 1
Share this question
or