简体   繁体   中英

ASP.NET MVC hangs when returning View() after performing some web request/response tasks

I have a controller action called UpdateSite(), browsing to this action is a manual way for me to kick off a (normally automated) data-collection process.

It's a fairly simple process which has the following work flow:

  1. Perform a couple of web requests for data using a web API
  2. Parse this data to extract anything I might need
  3. If some of the data is new and relevant, store it in a DB (using linq to sql)
  4. (optionally) send some data back to the API to let it know what I've just done.

Here's a contrived example of the method:

public ActionResult UpdateSite(string key)
        {
            if(key == KEY)
            {
                log4net.Config.XmlConfigurator.Configure();
                ILog log = LogManager.GetLogger("Default");
                string tUserName = ConfigurationManager.AppSettings["UName"];
                string tPassword = ConfigurationManager.AppSettings["UPassword"];

                ApiService apiSvc = new ApiService(tUserName, tPassword, new InterpreterFactory(),
                                                                    log);
                ControlPanel controller = new ControlPanel(Service, apiSvc, new DefaultAppStatusService(), log);

                CaptureResults results = controller.Capture();
                controller.EnrichData(results, new EnrichmentFactory(log));

                var newData = controller.PersistData(results);
                controller.ReplyWithNewData(newData);
            }
            return View();
        }

All this seems to run fine, it does its stuff, pulls back the data it needs from the external API writes it to the database etc.

The problem is that on "return View()" the page doesn't fully load in the browser and the site hangs permanently forcing me to restart the dev server. All the page has on it is a bit of text.

I have absolutely no idea what is going on. Has anyone else encountered something like this? Any ideas what it could be?

Does it happen that this process alters some file in the bin folder or any of its subfolders? If so it will recycle the AppPool and the request will "crash" with no chance.

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