I have an ASP.NET WebForm application - a main page that hosts a bunch of IFRAME "widgets". When main page loads - the widgets' pages load as well and begin their own processing, which include connecting to SQL Server to run stored procedures.
What would be the best way to cancel those IFRAME processing should user need to do so? I could probably set their SRC to another/blank page from client-side thus canceling the request, but if the IFRAME pages already called SQL Server - how do I cancel the SQL processing as well?
EDIT: To clarify the slowest point in the IFRAMEd page is the SQL Server stored procedure call, so essentially this boils down to - can I initiate cancellation of the SQL command from client?
One solution that came up in my mind is to have a static List
of currently Running SqlCommands
, whenever user invokes cancel you can extract the Command from this static list, and then cancel it. The page that is executing the command will receive the command cancel exception, it then can handle it appropriately.
Here are the things that you need to handle:
SqlCommand
using that key and call its Cancel
method.Update:
I am adding some details here,
Global.ascx
, so new controllers should workPageName
(as key) to the Cancel ControllerAs you may have already seen the project, it is using PageName
as Key to extract the SqlCommand
from List
. Due to this we have the limitation as I have mentioned above. Since PageName
will be same for multiple SqlCommand
s.
To overcome this limitation, you can generate a GUID
as Key and pass this GUID
in QueryString
to Form1.aspx
and Form2.aspx
pages, so that they add the command in List
using these GUID
s. These keys should be generated at the time of host page rendering or in JavaScript.
If you don't want to do the RnD, here is the updated project which uses GUID
as Key. :) http://goo.gl/I86S7Z