ASP.NET MVC hangs when returning View() after performing some web request/response tasks-Collection of common programming errors
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:
- Perform a couple of web requests for data using a web API
- Parse this data to extract anything I might need
- If some of the data is new and relevant, store it in a DB (using linq to sql)
- (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.