title: Routing problems with blazor, MVC and IIS
body: <p>I am trying to get blazor working in an existing MVC application hosted in IIS. I followed the example <a href="https://stackoverflow.com/questions/56241125/adding-server-side-blazor-to-an-existing-mvc-core-app">here </a></p>
  
  <p>There is also a similar example for razor pages. both work nicely in IIS express and self hosted, but when i try and use them in IIS they fail.</p>
  
  <p>When hosted in IIS the framework is registered to the site and not the application. when opened in chrome the console gives the following errors:</p>
  
  <p>blazor.server.js:1 Failed to load resource: the server responded with a status of 503 (Service Unavailable)
  favicon.ico:1 Failed to load resource: the server responded with a status of 503 (Service Unavailable)</p>
  
  <p>I tried changing the framework script refrence from <code>&lt;script src="_framework/blazor.server.js"&gt;&lt;/script&gt;</code> to <code>&lt;script src="~/_framework/blazor.server.js"&gt;&lt;/script&gt;</code>. This solves the initial error, but  blazor falls over at the next step :</p>
  
  <pre><code>[2020-03-05T09:46:07.566Z] Information: Normalizing '_blazor' to 'http://localhost/_blazor'.
  _blazor/negotiate?negotiateVersion=1:1 Failed to load resource: the server responded with a status of 503 (Service Unavailable)
  blazor.server.js:1 [2020-03-05T09:46:07.611Z] Error: Failed to complete negotiation with the server: Error: Service Unavailable
  e.log @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  s @ blazor.server.js:1
  Promise.then (async)
  c @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  B @ blazor.server.js:1
  e.getNegotiationResponse @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  B @ blazor.server.js:1
  e.startInternal @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  B @ blazor.server.js:1
  e.start @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  v @ blazor.server.js:1
  e.startInternal @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  v @ blazor.server.js:1
  e.startWithStateTransitions @ blazor.server.js:1
  e.start @ blazor.server.js:1
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  r @ blazor.server.js:8
  S @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  r @ blazor.server.js:8
  E @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  n @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  Show 22 more frames
  blazor.server.js:1 [2020-03-05T09:46:07.612Z] Error: Failed to start the connection: Error: Service Unavailable
  e.log @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  s @ blazor.server.js:1
  Promise.then (async)
  c @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  B @ blazor.server.js:1
  e.startInternal @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  B @ blazor.server.js:1
  e.start @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  v @ blazor.server.js:1
  e.startInternal @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  v @ blazor.server.js:1
  e.startWithStateTransitions @ blazor.server.js:1
  e.start @ blazor.server.js:1
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  r @ blazor.server.js:8
  S @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  r @ blazor.server.js:8
  E @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  n @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  Show 14 more frames
  blazor.server.js:15 [2020-03-05T09:46:07.612Z] Error: Error: Service Unavailable
  e.log @ blazor.server.js:15
  C @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  s @ blazor.server.js:8
  Promise.then (async)
  c @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  r @ blazor.server.js:8
  S @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  r @ blazor.server.js:8
  E @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  n @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  blazor.server.js:1 Uncaught (in promise) Error: Cannot send data if the connection is not in the 'Connected' State.
  at e.send (blazor.server.js:1)
  at e.sendMessage (blazor.server.js:1)
  at e.sendWithProtocol (blazor.server.js:1)
  at blazor.server.js:1
  at new Promise ()
  at e.invoke (blazor.server.js:1)
  at e. (blazor.server.js:15)
  at blazor.server.js:15
  at Object.next (blazor.server.js:15)
  at blazor.server.js:15
  e.send @ blazor.server.js:1
  e.sendMessage @ blazor.server.js:1
  e.sendWithProtocol @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  e.invoke @ blazor.server.js:1
  (anonymous) @ blazor.server.js:15
  (anonymous) @ blazor.server.js:15
  (anonymous) @ blazor.server.js:15
  (anonymous) @ blazor.server.js:15
  r @ blazor.server.js:15
  e.startCircuit @ blazor.server.js:15
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  a @ blazor.server.js:8
  Promise.then (async)
  c @ blazor.server.js:8
  a @ blazor.server.js:8
  Promise.then (async)
  c @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  r @ blazor.server.js:8
  E @ blazor.server.js:8
  (anonymous) @ blazor.server.js:8
  n @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  (anonymous) @ blazor.server.js:1
  favicon.ico:1 Failed to load resource: the server responded with a status of 503 (Service Unavailable)
  </code></pre>
  
  <p>The signalr hub seems to be pointing at the root site path in IIS instead of the application path.</p>
  
  <p>Does anybody know how I can resolve this? To recreate the problem just download the source code <a href="https://github.com/chrissainty/BlazorInExistingMVCApp" rel="nofollow noreferrer">here</a> and setup a debug configuration pointing to IIS</p>
  
  <p>Thanks</p>
  
  <p>Paul</p>