Two-way communication between ASP.NET Web App and C# Application

▼魔方 西西 提交于 2019-12-03 09:14:54

What you describe in your comment is typical three-tier application.

  • Front-end: ASP.NET application hosted in IIS
  • Back-end: .NET application running as Windows service (or WCF application hosted in IIS/WAS) with exposed web services. Front-end application communicates with this application using web services (or remoting).
  • Database: Accessed only by Back-end application.

Just to make it clear. Two-way has many meanings but common in this scenarios is that front-end makes call to back-end and back-end respond (request-response pattern). Back-end never calls front-end - such communication is very hardly achievable with ASP.NET application.

ASP.NET works on per request basis. Client calls your ASP.NET application and there is processing of the client request = that's where all logic runs. When the request is processed, the processing ends. So calling your ASP.NET application from back-end doesn't fit this unless you expose some special web service for back-end processing but even after that it will not correlate with your clients request processing without some internal state hold in ASP.NET application.

WCF might be a choice. You can build what kind of connection you need with WCF.

Also, I reccomend you to take a look at SignalR. It is a project which enables you to build a persistent connection between your web app and client app. (your C# app in this case.). In official words, SignalR is an async signaling library for ASP.NET to help build real-time, multi-user interactive web applications.

WCF would work and you may also want to look at consuming / writing a web Service but depending on if you want Sync or Async seem more like the question ..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!