I have a Wisej application with an associated API. The solution has multiple projects:
– App.API: an ASP.Net ApiController
– App.Services: a class library
Both the first 2 reference the 3rd and are deployed to the same IIS server as separate websites (application.com and api.application.com).
I have adapted https://wisej.com/blog/real-time-clock/ for real-time messaging. Within the Wisej app this works perfectly … an action in one browser session causes events in other browser sessions. Even though this is coded in the services app, calls from the API app (to that shared assembly) do not cause events in the Wisej app.
This is because the static object at the core of the messaging is unique to each process on the Windows Server (even if both website apps use the same application pool).
I can pursue Windows Interop messaging and build a whole ecosystem around the 2 disparate processes on the Windows Server talking to each other – but I’m hoping for some guidance on a more straightforward approach!
Do you have a solution that can work with the architecture described (ie. separate websites via a shared assembly), or is there an alternate approach? It seems to me that I can possibly build the ApiController into the Wisej project (application.com/api instead of api.application.com would be fine) however I couldn’t wrap me head around this – it would need to be “interpreted” outside of Wisej as I need instant response from the API (rather than the typical delay while Wisej loads into the browser).
Thanks in advance,
I may need some more advice!
I merged my API and Wisej projects (as described), ran it in VS2017 and everything works perfectly … pushing a message from within the Wisej app produces the expected event in all Wisej clients, and pushing a via the API also produces the expected event in all Wisej clients.
However I have now deployed this to the production (IIS) server, and while pushing a message from within the Wisej app produces the expected event in all Wisej clients, pushing a via the API does not produce the expected event in any Wisej clients.
I suspect this will be resolved with a simple IIS/site config tweak … can you advise?
Thanks in advance,
Thanks Luca, that was the guidance I needed. It was all rather painless.
In case it helps others …
(App.Wisej is the UI project, App.API is an ASP.Net ApiController created using the default Microsoft supplied template) …
App.Wisej: Installed the Microsoft.AspNet.WebApi Nuget package
App.Wisej: Installed the MultipartDataMediaFormatter.V2 Neget package
App.Wisej: Created an Api folder
App.Wisej: Moved all the cs files from App.API except Global.asax.cs into Api folder and added these to the project
App.Wisej: Updated Global.asax.cs with the App.API Application_Start code lines
You can’t share statics across app domains. Each web site in IIS runs in a separate AppDomain. Multiple AppDomains can be hosted in the same Application Pool, which is a single process.
You can host the api together with the wisej application. Wisej is only loaded by the html page through the wisej.wx script. Otherwise it’s just an aspnet handler. You can have as many web api, handlers, pages, ashx, aspx, routes, etc. all in the same project. If you move your api controller into the same site in IIS you can share statics easily.
Please login first to submit.