How to get feedback from a Web API Process in order to update Front-End

做~自己de王妃 提交于 2019-12-11 19:48:53

问题


I have a Web API built in ASPNET Web API application that has a Method that runs a lot of processes, like follows:

  1. File processed
  2. Inserting records to DB
  3. Applying rules to records
  4. Validating results

I would like to have a RealTime feedback from my server to my client in order to know what is the actual process that is being executed.

I would like something like the Dropbox upload screen:

I was reading that SignalR is a library for building RealTime applications.

Any clue or sample on how can I implement such functionality?


回答1:


SignalR can update your progress bars and indicators when it gets something back from the service, but as you said, you have one method which runs four different stages and you want to know when each state is completed. A SignalR Hub can't hook into your method and report on each call inside it being executed to the best of my knowledge.

What might solve your problem would be combining SignalR with a duplex service. The duplex service can issue a callback to your client after each stage is complete, SignalR can catch it, and update your client's UI, moving said progress bar along.



来源:https://stackoverflow.com/questions/22993190/how-to-get-feedback-from-a-web-api-process-in-order-to-update-front-end

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