2

I'm using SignalR for communication between my backend server and winform client. Well I tried to start the hub connection between those 2 but I got error from the client. It throw exception 405 Method is not allowed. It said:

{
    StatusCode: 405,
    ReasonPhrase: 'Method Not Allowed',
    Version: 1.1,
    Content: System.Net.Http.StreamContent,
    Headers: \r\ n {
        \
        r\ n Date: Tue, 27 Dec 2022 06: 42: 18 GMT\ r\ n Server: Kestrel\ r\ n Content - Length: 0\ r\ n Content - Type: text / plain\ r\ n
    }
}

It did some research about this error and tried everything from enable Cors, add useSignalr... which I'm already did. Anyone having the same issue? About the package: I'm using Microsoft.AspNet.SignalR.Core 2.4.3 on Server, Microsoft.AspNet.SignalR.Client 2.4.3 on Client. This is my Service try the hubconnection: My Service with the hub connection 405 Code

I tried to enable Cors, using the same version on server and client for SignalR, use differ packages. I was excepting that it will hit my Hub on my server but no.

Md.Sukel Ali
  • 2,987
  • 5
  • 22
  • 34
Superkriss
  • 21
  • 1
  • I saw you added `asp.net-core` tag, could you tell us what the .net version(.net core 6.0 or .net framework 4.8) in your project ? – Jason Pan Dec 27 '22 at 10:01
  • I use .net framework 4.5.2 in my project. My server using .net core 6 – Superkriss Dec 27 '22 at 10:12
  • And you mean your project for sever application is using .net core, and the project fro client winform is using .net framework ? – Jason Pan Dec 27 '22 at 10:15
  • Or both of server and client application are using .net framework, just in the server, you have installed .net core6 sdk. – Jason Pan Dec 27 '22 at 10:16
  • My server using .net 6.0 and my winform client using .net framework 4.5.2. – Superkriss Dec 28 '22 at 01:20
  • Ok, [this is the reason why you get the error message](https://stackoverflow.com/a/49153217/7687666). – Jason Pan Dec 28 '22 at 07:19
  • So SignalR won't work on my .net 6.0 server and my .net framework 4.5.2 client? I thought I use same 2.4.3 SignalR Core on server and SignalR.CLient 2.4.3 on client is ok? Same version of SiganlR :/ So any suggestion for me? – Superkriss Dec 28 '22 at 09:09

1 Answers1

1

I authored the link Jason referenced and I think that link does apply if you are trying to run .NET 4.x (client/server) with .NET CORE 6 (client/server). They don't mix and cannot be used together.

However, from your scenario it looks like you are running - "Microsoft.AspNet.SignalR.Core 2.4.3 on Server" and "Microsoft.AspNet.SignalR.Client 2.4.3"

Which are fine for a .NET 4.7/8 server. 1 issue I see here is "Content: System.Net.Http.StreamContent," will not work because this version does not support streaming (.NET CORE 6/7 does).

Your overall problem may be resolved by checking to see if you can or have .NET 4.7/8 on your server. According to this you should be able to have both but everything will still run in IIS (meaning .NET CORE 6/7 apps must as well in their own app pool).

Hopefully one of these help you resolve your issue.

Frank M
  • 1,379
  • 9
  • 18
  • But do you have any suggestion for me? I can't change my .NET core 6 server but still want to use SignalR because of its simplicity. – Superkriss Jan 04 '23 at 02:11
  • What is preventing you from using the ASP.NET Core SignalR Client? – Brennan Jan 04 '23 at 03:38
  • I'm using it and getting the error as the title....... – Superkriss Jan 04 '23 at 06:44
  • If you can't change the .NET Core 6 server then you will need to change to using the compatible .NET Core SignalR (not the one compatible with .Net Framework 4.x). You will need to update the client and the server. https://learn.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-6.0&tabs=visual-studio – Frank M Jan 04 '23 at 14:42