Windows Service and MVC communication - asp.net-mvc

I have a windows service (C#) that is getting data from other services, processing that data as saving it on the database.
Now I have monitoring application (C# Windows Forms) that monitors the windows service via TCP and xml messages.
But now I want to change my monitor app to MVC 4 web application.
My problem is how can I send notifications from my windows services to the each current client in my MVC application? The clients may be outside the internal network.
Can someone point me to the best approach?
Thanks
Pedro

You have already done much work:
Now I have monitoring application (C# Windows Forms) that monitors the
windows service via TCP and xml messages.
Pass your messages to the an web service that will be accessible by your MVC 4 web application clients.
you need interface between an windows service and the web application which is either a WCF service or Web Service. You can not access windows service in MVC4 application. If they are same machine or the location of XML message file is known and accessible to you then you can directly consume those in your MVC application.
otherwise the path will be Win Service -> WebService/WCF Service -> MVC4 application

Related

Why is it not recommended to host receive endpoints in a web application using MassTransit?

I am working on an ASP.NET MVC 5 application (based on nopCommerce). I want to use MassTransit to communicate with another application that is used for inventory management, billing, etc. It would be easier if I could add receive endpoints directly into the web application and not have to create a Windows service for that. But the MassTransit documentation says it is not recommended and there is no explanation as to why that is.
MassTransit in a web application
Configuring a bus in a web site is typically done to publish events,
send commands, as well as engage in request/response conversations.
Hosting receive endpoints and persistent consumers is not recommended
(use a service as shown above).
Does anyone know the reasoning behind it? Is it not safe to add receive endpoints in a web application? Will they not work properly?
Hosting endpoints in a web application is not recommended because web applications often restart for various reasons. These reasons are typically outside the control of the application itself.
While using a standalone Windows service is highly recommended, as long as the bus is properly started and stopped using the Application_Start and Application_End methods, it can be okay if you have no other options available.

.Net MVC Server to Server communications

I need to do some simple comms between two sites, including the case where the same website acts as both the client and server.
The client needs to call a server function with signature something like:
complexObject GetData( int, string)
I'm on c#, .Net MVC 4.5 and running on Windows 7 for dev and & Server 2008 for hosting. I'm looking at both Websockets and SignalR, but can't decide on suitability (I don't need javsacript support, it's purely client/server). There also seems to be limitations running Websockets below Windows server 2012, and on combining client & server in the same app/website ( I could remove that requirement if its a serious issue).
Any advice on the right way to go would be great.
You cannot use WebSocket in ASP.NET unless you are using Internet Information Server 8, so you would need Windows 8 or Windows 2012 server.
SignalR will fallback to SSE, ForeverFrame or LongPolling if you are not using IIS8. SSE is unidirectional from server to client, and does not work in IE.
You can host a WebSocket component in a worker role, that runs in the same domain but in different port. Running in the same domain, the WS connection will send the cookie during the HTTP negotiation, but you would have to work out how to associate the user identity.
You can use for example:
XSocket.NET: http://xsockets.net/
SuperSocket: http://superwebsocket.codeplex.com/
That said, you can still use other technologies for communicating from server to server, like a duplex WCF channel.
A Beginner's Guide to Duplex WCF
Duplex Service in WCF
Cheers.

Calling WCF callback service from a ASP.NET web app hosted in IIS

I have to develop a WCF callback service which will be accessed by the ASP.Net web application hosted in IIS or public internet. In this implementation clients should keep getting the updates from the service, so I thought of using WsDualhttpBinding, but I found few disadvantages of WCF callback service over internet.
How to use a WCF Dual Service over the internet? Any one please suggest any sample application for this?

Push Notification to .NET MVC3 application from Windows Azure SQL / WCF service

Can i have mechinism to have push notification to .NET MVC application once user comes online? Like facebook and gmail? I am going to deploy my app in 3 part.
1) MVC application
2) WCF Service
3) Azure SQL
Everything would in Windows Azure.
Thanks.
If I understand your question correctly, then you might be interested in SignalR. Here is the link http://signalr.net. SignalR allows you to push content from the server to the client. It comes with client side js library and also server side component. SignalR is very easy to implement and provides a very powerful set of abstractions that otherwise would be very difficult to program.

Using Service Bus for Asp.net Web API

I am developing Services using ASP.NET Web API and have plan to use Service Bus for message exhanging. Is it possible to use Service Bus along with ASP.NET Web API?
And what are the Microsoft's Answer for Service Bus other than Windows Azure service bus?
There is absolutely nothing stopping you from using a service bus with ASP.NET Web API.
I am doing exactly this (web api) in a project I am implementing where a user registers and I need to send an activation e-mail. The e-mail sending is handled from a service bus endpoint so that the registration from the web api returns immediately.
I have also implemented my service bus in a production system although it is MVC 3 (4 web servers).
Although any service bus should do the trick (NServiceBus, MassTransit, etc.) you may want to have a look at my FOSS Shuttle ESB project: http://shuttle.codeplex.com/
Have you looked at Microsoft Service Bus 1.0?
http://msdn.microsoft.com/en-us/library/windowsazure/jj193022(v=azure.10).aspx
(it includes messaging and queuing features from the Azure Service Bus)
For distributed caching (i.e. Caching Service in Azure)
AppFabric 1.1 for Windows Server has as lot of features
http://www.microsoft.com/en-us/download/details.aspx?id=27115
You can absolutely use the Caching Service in the ASP.NET Web API. I have not tried the Microsoft Service Bus 1.0 for messaging/queuing on Web API.

Resources