0

I am trying to create a signalR hub in asp.net but i have problems with it on server. It works ok on my local machine. The error i get it:

Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

The code is:

 var hubConnection = new HubConnection("http://server_name/appName/");
 hubConnection.Start().Wait();

I can see that the hubConnection url is correct because it's the same as the one provided in the constructor, which means: http://server_name/appName/signalr/

The full stacktrace is:

at Newtonsoft.Json.JsonTextReader.ParseValue() at Newtonsoft.Json.JsonTextReader.ReadInternal() at Newtonsoft.Json.JsonTextReader.Read() at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value) at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.b__1(String raw) at Microsoft.AspNet.SignalR.TaskAsyncHelper.<>c__DisplayClass192.<Then>b__17(Task1 t) at Microsoft.AspNet.SignalR.TaskAsyncHelper.TaskRunners2.<>c__DisplayClass42.<RunTask>b__41(Task1 t)

Also, on IIS i don't have forms authentication, only the Anonymous Authentication is enabled.

PS: i have read the other questions related to this but none of them applies here. (the questions i've read are: this, this and this)

Community
  • 1
  • 1
Zippy
  • 1,804
  • 5
  • 27
  • 36

1 Answers1

0

This is basically Json.NET trying to parse a string and seeing the '<' character at the beginning which means it's not proper json.

There's usually two general possibilities:

  1. Your url returns HTML and that first character is the start of the document
  2. Your url return XML

Try catching the string and see what it is.

hyp
  • 1,370
  • 1
  • 9
  • 21
  • How could i catch the string? Because fiddler doesn't show the signalr request... – Zippy Aug 05 '16 at 08:51
  • I'm guessing you're hooking up a website to the endpoint? You could use the browser debugging tools to look at the network activity. – hyp Aug 05 '16 at 10:30