11

I am debugging an ASP page with visual studio 2013.

So, i set a breakpoint, the breakpoint gets hit, and the execution gets on hold.

Now, i just want to abort the current request stop executing the code for the current request (which is on hold as it had hit the breakpoint), without having to stop debugging and run again the project.

This seems too simple, yet i haven't figured out how to do it.

Let me explicity state that clicking "restart" is not what i need, as "restart" is just a shortcut to stop project and run again.

Sharky
  • 6,154
  • 3
  • 39
  • 72
  • are you debugging .aspx page or .cs file? – MANISH KUMAR CHOUDHARY Jun 24 '16 at 12:01
  • @MANISH .ashx and .aspx – Sharky Jun 24 '16 at 12:02
  • you can simply continue the execution. Or can directly drag the execution pointer to any specific line if you want – MANISH KUMAR CHOUDHARY Jun 24 '16 at 12:05
  • 2
    @MANISH i wrote **"i just want to abort the current request"** that means i do **not** want to "simply continue the execution". – Sharky Jun 24 '16 at 12:06
  • Go to properties of your project and enable "allow unsafe code" (depending on VS version could be in Build or Debug tab). Clear you solution, compile and once you hit breakpoint try Request.Abort() in your Command Window. – derloopkat Jun 24 '16 at 12:34
  • @derloopkat im calling HttpContext.Current.Request.Abort() as you described, it does not produce any errors, **client stops waiting for response**, but strangely, **execution does not stop** (?!) Then, if i press continue, the next breakpoint a couple of lines below gets hit. Nice try though, i thought it was going to work :/ – Sharky Jun 24 '16 at 13:32
  • Not sure what you mean. Did you expected to be kicked out just for running Request.Abort()? Do you mean you want to abort current thread instead? – derloopkat Jun 24 '16 at 13:44
  • What you are asking for is not part of the visual studio debugging process. unless you manually return form the request after the break point the process is going to continue running. when debugging you are just an observer of the process. either the code kills the process via exception or returns from execution, or you kill the process externally. As mentioned by a previous commentor you could drag the pointer to the end of the method and then click play to continue processing. otherwise there isn't much else you can do – Nkosi Jun 24 '16 at 13:53
  • @derloopkat yes i want to abort the execution of that thread – Sharky Jun 24 '16 at 14:32
  • @Nkosi does VS provide a way to kill that specific thread being observed? – Sharky Jun 24 '16 at 14:47
  • not without stopping the whole process. while debugging you can view the threads Debug -> Windows -> Threads or Ctrl+D,T – Nkosi Jun 24 '16 at 14:48
  • @Nkosi i know, closest i can get is kill the whole iis express process with process explorer, which is not what i want. after a bit of investigation it looks like it is not possible http://stackoverflow.com/a/1327245/953684 at least in an elegant way – Sharky Jun 24 '16 at 14:49
  • @Nkosi also, thanks for the information :D – Sharky Jun 24 '16 at 14:50

1 Answers1

5

Based on our conversation in the comments, I am placing this as an answer.

What you are asking for is not part of the visual studio debugging process. unless you manually return from the request after the break point the process is going to continue running. When debugging you are just an observer of the process. Either the code kills the process via exception or returns from execution, or you kill the process externally.

It does not looks like what you are asking for is possible, and that is by design.

Nkosi
  • 235,767
  • 35
  • 427
  • 472
  • 3
    `or you kill the process externally` in the immediate window run `System.Threading.Thread.CurrentThread.Abort();`. Beware, it has the potential to mess up with `using - finally` blocks. https://www.interact-sw.co.uk/iangblog/2004/11/12/cancellation – Sharky Sep 18 '17 at 08:31