Chat with SignalR | Angular 8 | ASP.NET-Core 2.1

I try to repeat example with chat. Such here . But as I undesrtand I have a problem with adress of my host. This is what I have when my component started.

enter image description here

As you can see I have the twice adress. I tried only /chat but the same result

The app I start in VS. I dont start as a separate client part and api-becked.

This is web-adress of my app where I start my component with chat. http://localhost:59955/home/message

My code

public class ChatHub : Hub
public async Task Send(string name, string message)
    await this.Clients.All.SendAsync("sendToAll", name, message);

Start-up and what I added.

services.AddCors(o => o.AddPolicy("CorsPolicy", builder =>

And I method public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.UseSignalR(routes =>

Now the client

export class ChatComponent implements OnInit {
// tslint:disable-next-line:variable-name
private _hubConnection: HubConnection;
nick = '';
message = '';
messages: string[] = [];

constructor() { }

ngOnInit() {
this.nick = window.prompt('Your name:', 'John');

this._hubConnection = new 

  .then(() => console.log('Connection started!'))
  .catch(err => console.log('Error while establishing connection :('));

public sendMessage(): void {
 this._hubConnection.on('sendToAll', (nick: string, receivedMessage: string) 
 => {
  const text = `${nick}: ${receivedMessage}`;
  .invoke('sendToAll', this.nick, this.message)
  .catch(err => console.error(err));

There is launchSettings json file.

enter image description here

In what problem?

Read more here:

Content Attribution

This content was originally published by FX_Sektor at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: