从Windows服务调用Javascript函数 [英] Call Javascript function from Windows Service

查看:56
本文介绍了从Windows服务调用Javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个在服务器上运行的Windows服务。我有一个html文件(也在IIS上部署,如www.xyz.com/index.html),它有一个javascript库,其中包含带参数的函数。我想通过使用Windows服务的参数调用此JS中的特定函数。是否可以从Windows服务中调用JS函数?给我一些想法.......



提前致谢



KP Singh Chundawat

Hello folks,

I have one windows service which runs on server. I have one html file(which is also deploy on IIS Like www.xyz.com/index.html) which has one javascript library which have number of function with arguments. I want to call specific function from this JS with argument using Windows service. Can it be possible to call JS function from Windows service??? give me some idea.......

Thanks in advance

KP Singh Chundawat

推荐答案

你的问题的答案:不,你不能。这有很多原因。


我想假设服务器端有一个事件,来自Windows服务,你想要所有或一些活跃的客户端对此做出反应(例如,通过发送一些尚未发送到服务器端的数据)。 Windows服务永远无法访问客户端。 Web应用程序也不能在iis下托管。但是您的客户端可以针对该特定事件轮询Web应用程序,该事件可以使用某些IPC轮询Windows服务。实际上你也可以公开windows服务,但我不建议这样做。



作为替代 SignalR [ ^ ]是一个很棒的工具,你可以使用,但你仍然需要将客户视为该通信的发起者。
The answer to your question: no, you can't. There are many reasons for that.

Let me suppose that there is an event on server side, comming from the windows service, and you want all or some active clients to react to that (for example by sending some data not yet sent to the server side). The windows service will never be able to access the client. Neither can the web application hosted under iis. But your client can poll the web application for that specific event, which can poll the windows service using some IPC. Actually you could expose the windows service also, but I don't recommend that.

As an alternative SignalR[^] is a great tool you can use, but you still need to think about the client as the initiator of that communication.


这篇关于从Windows服务调用Javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆