VS2015 + MVC + URL Rewrite + Hangfire + OwinStartup + F5 Debug => Unknown error: 0x80004005

Introduced Hangfire 1.6.8 to an MVC project, built in VS 2015, and running on a local IIS 10.0 (win 10).

When the MVC project was originally started, it had all OWIN references removed, as they are not used.
But when adding Hangfire and its Dashboard, the Dashboard requires OWIN, so I’ve added the references back in.

When I press F5 in VS2015 to start up a debug instance, Visual Studio throws the following error:

“Unable to start debugging on the web server. Operation not supported. Unknown error: 0x80004005.”

One can press OK, and manually attach to the w3wp.exe process, and everything works fine (can browse to the Hangfire dashboard).
But I do not want to commit a change, which messes with all the other developers F5 debug.

If the following URL Rewrite (2.0) rule is commented out, the error disappears (along with the URL rewrite):

<rule name="Remove WWW and redirect to HTTPS" enabled="true" stopProcessing="true">
   <match url="(.*)" />
   <conditions logicalGrouping="MatchAny">
      <add input="{HTTPS}" pattern="^OFF$" />
      <add input="{HTTP_HOST}" pattern="^www\." />
   </conditions>
   <action type="Redirect" url="https://localhost/MyApplication/{R:1}" redirectType="SeeOther" />
</rule>

I’ve tried adding a rule before the above rule, to skip https rewrites for hangfire using:

<rule name="Skip rewrite for Hangfire" enabled="true" stopProcessing="true">
   <match url="^hangfire.*" />
   <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
   </conditions>
   <action type="None" />
</rule>

I’ve also tried:

  • adding <location path="...> around <system.webServer><rewrite> in the web.conf and specify the rewrite for “.” and one which doesn’t rewrite for “hangfire”
  • clearing: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
  • Resetting IIS
  • Trace URL Rewriting using “Failed Request Tracing”, which only outputs that the URL rewrite with status 303 (“SeeOther”) took place.

Here is the OWIN Startup class, in case of interest:

[assembly: OwinStartup(typeof(MyApplication.Startup))]
namespace MyApplication
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            GlobalConfiguration.Configuration
                .UseSqlServerStorage("HangfireConnectionStringInWebConf");

            app.UseHangfireDashboard();
            app.UseHangfireServer();
        }
    }
}

Any suggestions of where to find more information about why the error occurs, or possible solutions are most welcome.

/Chris