locked
ASP.NET 5 - app.UseSignalR - error RRS feed

  • Question

  • User-953595010 posted

    Hello,

    I'm trying out SignalR based on the book "SignalR Programming in Microsoft ASP.NET". I'm running ASP.NET 5 with 1.0.0.-rc1-update1. I already there are some changes: eg I suppose app.MapSignalR is replaced by UseSignalR?

    This is my project.json

    {
      "version": "1.0.0-*",
      "compilationOptions": {
        "emitEntryPoint": true
      },
    
      "dependencies": {
        "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
        "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
        "Microsoft.AspNet.SignalR.Server": "3.0.0-rc1-final"
      },
    
      "commands": {
        "web": "Microsoft.AspNet.Server.Kestrel"
      },
    
      "frameworks": {
        "dnx451": { },
        "dnxcore50": { }
      },
    
      "exclude": [
        "wwwroot",
        "node_modules"
      ],
      "publishExclude": [
        "**.user",
        "**.vspscc"
      ]
    }
    

    I have the following code in Startup.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNet.Builder;
    using Microsoft.AspNet.Hosting;
    using Microsoft.AspNet.Http;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.AspNet.SignalR;
    
    namespace SignalRTest
    {
        public class Startup
        {
            // This method gets called by the runtime. Use this method to add services to the container.
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
            public void ConfigureServices(IServiceCollection services)
            {
                
            }
    
            // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
            public void Configure(IApplicationBuilder app)
            {
                app.UseIISPlatformHandler();
    
                app.UseSignalR<EchoConnection>("/echo");
    
    
                app.Run(async (context) =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
            }
    
            // Entry point for the application.
            public static void Main(string[] args) => WebApplication.Run<Startup>(args);
        }
    }
    

    everything builds fine but when running my project I get:

    An exception of type 'System.InvalidOperationException' occurred in Microsoft.AspNet.Http.Abstractions.dll but was not handled in user code

    Additional information: Unable to resolve service for type 'Microsoft.Extensions.OptionsModel.IOptions`1

    "app.UseSignalR<EchoConnection>("/echo"); is the cause of this runtime error."

    Anyone can help me to resolve this?

    Thanks.
    Guy

    Sunday, December 13, 2015 12:14 AM

Answers

All replies