title: How do I Specify the Correct Back-End URL for SignalR 3.0 When I have Two Projects in my Solution? Currently Getting 404
body: <p>Getting this error in my SignalR project:</p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404,
  </code></pre>
  
  <p>... fired some time after I invoke <code>connection.start()</code></p>
  
  <p>After succeeding with <a href="https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-3.0&amp;tabs=visual-studio" rel="nofollow noreferrer">this tutorial</a>, I modified it use two projects in a single solution, a back-end and a front-end.</p>
  
  <ul>
  <li>Back-end is a .NET Core Web API project</li>
  <li>Front-end is .NET Core Web Application</li>
  </ul>
  
  <p>In the back-end startup.cs file, I attempt to specify the URL using 'ChatHub', like this:</p>
  
  <pre><code>app.UseEndpoints(endpoints =&gt; {
      endpoints.MapControllers();
      endpoints.MapHub&lt;ChatHub&gt;("/chatHub");
  });
  </code></pre>
  
  <p>I placed the code above in the Startup.cs file of my back-end project. Also added <code>services.AddSignalR();</code> in same file, in <code>ConfigureServices</code> method, per the tutorial.</p>
  
  <p>I cut-and-pasted my Hub code from the tutorial.</p>
  
  <p>Besides the error message above, the debugger further indicates:</p>
  
  <ul>
  <li><code>Information: Normalizing '/chatHub' to 'https://localhost:44365/chatHub'</code></li>
  <li><code>Error: Failed to complete negotiation with the server</code></li>
  </ul>
  
  <p>I literally cut-and-pasted the JavaScript for my front-end, note the URL shown below on line 2, which should match the endpoint above:</p>
  
  <pre><code>"use strict";
  
  var connection = new signalR.HubConnectionBuilder().withUrl("/chatHub").build();
  
  //Disable send button until connection is established
  document.getElementById("sendButton").disabled = true;
  
  connection.on("ReceiveMessage", function (user, message) {
      var msg = message.replace(/&amp;/g, "&amp;amp;").replace(/&lt;/g, "&amp;lt;").replace(/&gt;/g, "&amp;gt;");
      var encodedMsg = user + " says " + msg;
      var li = document.createElement("li");
      li.textContent = encodedMsg;
      document.getElementById("messagesList").appendChild(li);
  });
  
  connection.start().then(function () {
      document.getElementById("sendButton").disabled = false;
  }).catch(function (err) {
      return console.error(err.toString());
  });
  
  document.getElementById("sendButton").addEventListener("click", function (event) {
      var user = document.getElementById("userInput").value;
      var message = document.getElementById("messageInput").value;
      connection.invoke("SendMessage", user, message).catch(function (err) {
          return console.error(err.toString());
      });
      event.preventDefault();
  });
  </code></pre>
  
  <p>This code throws the error listed above. I tried some variations on the URL, including <a href="https://localhost:44365/BackEnd/ChatHub" rel="nofollow noreferrer">https://localhost:44365/BackEnd/ChatHub</a>. No luck.</p>
  
  <p>Then I tried splitting my solution and running each project separately. Revised my JavaScript to use the back-end port, like this:</p>
  
  <pre><code>var connection = new signalR.HubConnectionBuilder()
      .withUrl("https://localhost:44384/chatHub")
      .build();
  </code></pre>
  
  <p>But when I examined the browser, it indicated </p>
  
  <pre><code>Information: Normalizing '/chatHub' to 'https://localhost:*44365*/chatHub'.
  </code></pre>
  
  <p>Note the port it used is the wrong port, it is the port for the front-end.</p>
  
  <h2>Summary</h2>
  
  <p>I believe I took a working tutorial and modified it only by splitting it into two projects, but I can't figure-out the URL to connect to my back-end. I tried variations on the URL, for some reason it didn't use the correct port when I split-out the back-end project from my original solution</p>
  
  <p><a href="https://i.stack.imgur.com/7wq5o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7wq5o.png" alt="Screen shot shows JavaScript errors in console"></a></p>