I want to achieve this:
When my website is published by webdeploy/started/restarted, the website automatically run a task to send a post method to another site.
How can I create a task only run once?
It seems hangfire can't do this.
I want to achieve this:
When my website is published by webdeploy/started/restarted, the website automatically run a task to send a post method to another site.
How can I create a task only run once?
It seems hangfire can't do this.
Hi @melonNG-6986 Could you please tell me what you mean about create a task only run once? Normally, we could run some command by modifying the publish profile or else to run some cmd command. But you mean after you set it, you just want to run this task only once? If we republish this application, you don't want to run this task again?
I want to task running in the back-end but not by modifying the publish profile or some cmd command that is running by a third-party program.
Every time I republished/restart my project, the task will run. It is used to tell the remote sites to clear the old cache and cache new data from my website.
In my opinion, you want to achieve your requirement, I suggest you could consider using the third-party program to publish your application. For example, you could use web deploy command to publish your web site instead of using visual studio. Since visual studio publish doesn't contains this feature to trigger something when publish unless modify the csproj or publish profile.
just put the call in startup.cs use async task, and don't await as you want to fire and forget.
3 people are following this question.