This question comes up rather often in my job, and this post by Adam Turoff answers the question by including “when” as a variable. In short, the sooner a project needs to succeed, the less likely it is that a rewrite will succeed.
Whenever I come across an application that isn’t designed or implemented as well as it should be, I’m biased in favor of rewriting the application. That approach tends to meet resistance because the “when” is usually very short. Refactoring is a good fallback option, but only if the application is relatively current. My desire to refactor single-tier classic ASP is nil.