I have an asp.net app which might run long running queries. I would like the user to have the ability to cancel the query in SQL Server. I tried using BeginExecuteReader & EndExecuteReader using asynchronous operations with waithandles but all this does is cancel the thread after the waithandle's timeout is reached. The query is still running in SQL Server however. I can't use KILL command because this requires sysadmin or processadmin roles and the app's connection user is not allowed to have these elevated roles.
How can an ASP.NET cancel their query on demand? Just like hitting the stop button in SSMS but doing this using a button in a web page. Or signal SQL Server to stop the query as soon as possible without waiting for it to finish? (Using SQL Server 2012 & .NET 4.5)
UPDATE
I am adding this clarification. The user doesn't know upfront that the query will take a long time. For example they entered a huge date range by mistake, hit submit and go "oh oh!". They need to cancel now.