简体   繁体   中英

How to handle long running operation in Sitecore website?

I've a Sitecore website, where I created a webform on the website root ( DataImport.aspx ), which imports data from Wordpress to Sitecore . On this page I wrote the code to get blog posts from Wordpress , then for each post create a Sitecore Item & download all media to the /uploads folder.

This task takes several minutes to complete (around 10-15 minutes) as we are downloading a large number of media files & I'm getting "Request Timeout" error on browser.

After doing research I found that if we update the executionTimeout setting in web.config it will work fine, but even after updating this to 6000 seconds I'm still getting the same error.

Another thing I would like to ask is what is the best approach when we are doing such tasks? Like, should I create a background process or create a web service?

You should use a Sitecore Job to take care of your long running operations, which will run as a background task, be non-UI blocking and allow you to give feedback to the user. You can even run them as a scheduled task.

Some reference articles:

Setting executionTimeout is the correct approach. If you set this high enough, your process will continue running. What you are seeing might be your browser giving up - however your process will continue executing in the background until terminated. If you do any logging as part of your job, you will see the logfiles getting updated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM