Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. Error: InnerException: System.InvalidOperationException
  2. HResult=-2146233079
  3. Message=There was an error invoking Hub method 'Test.DetermineLength'.
  4.  
  5. public class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string url = @"http://localhost:8080/";
  10. using (WebApp.Start<StartUp>(url))
  11. {
  12. Console.WriteLine(string.Format("Server running at {0}", url));
  13. Console.ReadLine();
  14. }
  15. }
  16. public class StartUp
  17. {
  18. public void Configuration(IAppBuilder app)
  19. {
  20. app.UseCors(CorsOptions.AllowAll);
  21. app.MapSignalR();
  22. }
  23. }
  24. [HubName("Test")]
  25. public class TestHub : Hub
  26. {
  27. [Authorize]
  28. public void DetermineLength(string message)
  29. {
  30. Console.WriteLine(message);
  31. string newMessage = string.Format(@"{0} has a length of: {1}", message, message.Length);
  32. Clients.All.ReceiveLength(newMessage);
  33. }
  34. }
  35. }
  36.  
  37. public class Program
  38. {
  39. static void Main(string[] args)
  40. {
  41. IHubProxy _hub;
  42. string url = @"http://localhost:8080/";
  43. var connection = new HubConnection(url);
  44. _hub = connection.CreateHubProxy("Test");
  45. connection.Start().Wait();
  46. string line = null;
  47. while ((line = System.Console.ReadLine()) != null)
  48. {
  49. _hub.Invoke("DetermineLength", line).Wait();
  50. _hub.On("ReceiveLength", x => Console.WriteLine(x));
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement