Last active
March 2, 2022 00:25
-
-
Save DevEarley/84016b82dcc8eaa0ce5942ad6a3a0a74 to your computer and use it in GitHub Desktop.
Nancy set up with signalr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Owin; | |
using Nancy.Owin; | |
using System; | |
using Microsoft.Owin; | |
using Microsoft.AspNet.SignalR; | |
[assembly: OwinStartup(typeof(SomeAPI.Startup))] | |
namespace SomeAPI | |
{ | |
public class Startup | |
{ | |
public void Configuration(IAppBuilder app) | |
{ | |
app.MapSignalR().UseNancy(); | |
} | |
} | |
} | |
using Microsoft.AspNet.SignalR; | |
using Microsoft.AspNet.SignalR.Hubs; | |
namespace SomeAPI | |
{ | |
[HubName("stuff")] | |
public class StuffHub :Hub | |
{ | |
public void UpdateStuff() | |
{ | |
Clients.All.RefreshStuff(); | |
} | |
} | |
} | |
/* Web.config | |
<?xml version="1.0" encoding="utf-8"?> | |
<!-- | |
For more information on how to configure your ASP.NET application, please visit | |
https://go.microsoft.com/fwlink/?LinkId=301879 | |
--> | |
<configuration> | |
<appSettings> | |
<add key="ClientValidationEnabled" value="true" /> | |
<add key="UnobtrusiveJavaScriptEnabled" value="true" /> | |
<add key="vs:EnableBrowserLink" value="true"/> | |
</appSettings> | |
<system.web> | |
<compilation debug="true" targetFramework="4.5.2" /> | |
<httpRuntime targetFramework="4.5.2" /> | |
<httpHandlers> | |
<add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" /> | |
</httpHandlers> | |
</system.web> | |
<system.webServer> | |
<handlers> | |
<remove name="ExtensionlessUrlHandler-Integrated-4.0" /> | |
<remove name="OPTIONSVerbHandler" /> | |
<remove name="TRACEVerbHandler" /> | |
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /> | |
<add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" /> | |
</handlers> | |
<validation validateIntegratedModeConfiguration="false" /> | |
<httpErrors existingResponse="PassThrough" /> | |
<modules runAllManagedModulesForAllRequests="true"> | |
<remove name="WebDAVModule" /> | |
</modules> | |
</system.webServer> | |
<runtime> | |
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |
<dependentAssembly> | |
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" /> | |
</dependentAssembly> | |
<dependentAssembly> | |
<assemblyIdentity name="Microsoft.AspNet.SignalR.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-2.2.2.0" newVersion="2.2.2.0" /> | |
</dependentAssembly> | |
<dependentAssembly> | |
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" /> | |
</dependentAssembly> | |
<dependentAssembly> | |
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> | |
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" /> | |
</dependentAssembly> | |
</assemblyBinding> | |
</runtime> | |
<system.codedom> | |
<compilers> | |
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> | |
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> | |
</compilers> | |
</system.codedom> | |
</configuration> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment