Aborting ASP.net page's SQL query

For the past week, I've been working on solving a problem that involves creating 2 buttons - "Execute" and "Cancel". Clicking "Execute" triggers a lengthy SQL query, while clicking "Cancel" should stop the query. The issue arises when two ajax queries are sent to the server sequentially, making it impossible for the "cancel" click handler function to interrupt the previous query, despite having a method to cancel it (Q.cancel()). This seems to be related to "locking the Session".

Even redirecting the user to another webpage upon clicking "cancel" has proven difficult due to the ajax call for "execute" blocking other activities until completion.

I attempted to use Microsoft's Reactive Extensions (Rx.NET) library in hopes of running the "execute" process on a separate thread. However, I encountered difficulties as I did not wait for that thread to finish and return results from the query.

If anyone could provide assistance, excluding suggestions like "Don't cancel it," it would be greatly appreciated.

Answer №1

Typically, it is recommended to process requests on separate threads from the thread pool. It seems like you may be utilizing IISExpress or restricting your thread count on IIS to just one.

In addition to examining your IIS configurations, I suggest exploring the use of asynchronous handlers for handling long-running requests since they do not tie up threads. By doing this, a single thread can manage both the Execute and Cancel requests, although you will need to keep a CancellationToken stored somewhere like in the Session state.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Clicking outside of a focused div does not trigger a jQuery function

Check out this HTML snippet: $html .= " <td><div class='edit_course' data-id='{$id}' data-type='_title' contenteditable='true'>{$obj->title}</div></td>"; Next, see the jQuery code below: ...

PHP mail function causing email to be filtered as spam

I've been using this code to send emails, but unfortunately, the emails are ending up in the spam folder. I've tried sending through both Gmail and Hotmail, with the same result. Here's the PHP code: <?php if($_POST) { //check if its an ...

Transferring data from AJAX to PHP class methods

Q. Is it feasible to transfer data from ajax to a specific php class with functions? For instance, verifying a username on the registration form to check if the user already exists. This form is straightforward and will gather a username input along with ...

How can AJAX be used for form validation prior to submission?

Currently, I am facing an issue with validation on the client side when making an ajax cross-domain request to my PHP server page. I have a standard HTML form that posts input fields such as name, last name, and message. Here is an example of my form on th ...

"Enhance your web application with dynamic drop-down selection using Spring, Ajax

In my JSP file, I have a script that populates the list of states based on the selected country. The script fetches data from the controller and is supposed to display the list of states. However, after calling the controller method, the alert "received da ...

Deactivate the date when it reaches 8 in the current date count using ajax, php, and mysql

I want to prevent users from selecting a specific date after it has been chosen 8 times. Currently, when the date is selected for the 9th time, an alert box pops up. Instead of the alert box, I would like to disable that particular date selection altogethe ...

The AJAX response containing jQuery is failing to produce any visible changes

On Page 1 of my website, there is a form that, upon submission, loads Page 2 using jQuery. This process involves calling a PHP page and displaying the output on Page 1 without actually reloading the entire page. To maintain security, I have set up session ...

Troubleshooting Issue with Google Analytics Event Sending upon Ajax Success Failure

I've created a Process Transaction Knockout method that retrieves a transaction status. Depending on this status, I want to trigger an event in analytics.js. Despite using analytics-debug.js and seeing "Send finished" in the console, the event never a ...

Looking for a resolution with NicEditor - Seeking advice on incorporating custom select options

I recently started using NICInline Editor and found a helpful sample at Is there a way to incorporate custom options into this editor? I would like the selected option's value to be inserted right at the cursor point of the Editor Instance. Query: H ...

Error in Node.js: [Error: Query parameter should not be empty]

I've been recently focusing on a project that involves sending the required name to my profile.js file using a POST request. However, whenever I try to access console.log(req.body.bookName) (as the data being sent is named bookName), it shows an error ...

Make sure to use jQuery waterfall 'reflow' only once all the images have finished loading

Currently, I am utilizing jQuery waterfall to achieve a grid-style display on my website. To address the issue of images overlapping, I have enclosed the waterfall method within a .load() function like this: $(window).load(function(){ $('#buildcon ...

Is there a method to communicate with controls via a web interface?

I've been exploring the possibility of interacting with ASP controls from within a webmethod. My initial thought was that I could achieve this by identifying the page where the webmethod was called from and then locating and updating controls on that ...

The function $.getJSON() seems to be non-responsive

I've been struggling to solve this issue for quite some time now. The users.json file that I am using can be found in the "JSON" folder alongside the other files. The alert("Before") is functioning properly, but I'm facing difficulty with getting ...

Is there a way to use AJAX for transferring a value?

I am looking to transmit a value to a php-script (servo.php) that will then write the received data in a file (/dev/servoblaster). The script section of my HTML file (index.html): <script> function tiltt() { var tilt = document.getElementById("tilt ...

Having trouble sending form data using the jQuery AJAX POST method?

I am facing an issue with a simple form that is supposed to send data to PHP via AJAX. However, when I submit the form, the data does not get sent across. Here is the JavaScript code: $(document).ready(function(e) { $('#update').submit(func ...

Issue with Ajax request in Laravel failing to function when ad blocker is active

While utilizing Laravel to send Ajax requests, everything functions properly on localhost. However, once I test it on the live server with an adblocker enabled, it fails to work. Once the adblocker is disabled, the functionality returns. domain.com/sponso ...

Tips for updating DataTable data following a database update:

Struggling with this issue: I've created a view containing PrimeFaces components like <p:datatable /> and <p:contextMenu />. The contextMenu has an actionListener attribute that triggers a method in the Managed Bean to update the current ...

Safeguarding intellectual property rights

I have some legally protected data in my database and I've noticed that Google Books has a system in place to prevent copying and printing of content. For example, if you try to print a book from this link, it won't appear: How can I protect my ...

struggling with responseText functionality in javascript

I am encountering an issue with passing variables from PHP to JavaScript using JSON. The problem lies in the fact that I am able to debug and view the items in the responseText within my JavaScript, but I am unable to assign them to a variable or properly ...

What is the best way to manage an ajax request response within the Flux Architecture?

After reviewing the Flux Documentation, I'm struggling to understand how to incorporate code for an AJAX update and fetch within the dispatcher, store, component architecture. Does anyone have a straightforward example of fetching data from the serve ...