c# - Self-Host SignalR and Local Http Server on the same port -
i want host a self-host signalr process locally on port 80 , having local http directory hosted on same port (serving files directory, mapping directory construction http requests).
for illustration accessing localhost:80/index.html homecoming html file located in directory, communicates signalr process on same port, because having different ports cause error in chrome browser due same origin policy.
any thought how can accomplish it? since cannot bind same port 2 different applications.
as long we're talking signalr 2.x , can serve other content via webapi, possible since both utilize owin. mvc, things more complicated.
to run signalr , webapi on same port, you'd have install microsoft.aspnet.webapi.owinselfhost in signalr applilcation , modify owin.iappbuilder utilize web api:
public static class startup { public static void configuration(iappbuilder app) { var httpconfig = new httpconfiguration(); httpconfig.routes.maphttproute("default", "api/{controller}/{id}", new {id = routeparameter.optional}); app.usewebapi(httpconfig); app.mapsignalr(); } } note use cors around browser issue.
c# localhost signalr self-hosting
No comments:
Post a Comment