简体   繁体   English

执行一些Web请求/响应任务后返回View()时,ASP.NET MVC挂起

[英]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. 我有一个名为UpdateSite()的控制器操作,浏览到该操作是手动启动我(通常是自动化的)数据收集过程的方式。

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 使用Web API执行几个Web数据请求
  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) 如果某些数据是新数据且相关,则将其存储在数据库中(使用linq to sql)
  4. (optionally) send some data back to the API to let it know what I've just done. (可选)将一些数据发送回API,以使其了解我刚刚所做的事情。

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. 所有这些似乎运行良好,可以完成工作,从外部API提取所需的数据并将其写入数据库等。

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. 问题是,在“返回View()”上,页面没有完全加载到浏览器中,并且站点永久挂起,迫使我重新启动开发服务器。 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? 是否发生此过程更改bin文件夹或其任何子文件夹中的某些文件的情况? If so it will recycle the AppPool and the request will "crash" with no chance. 如果是这样,它将回收AppPool,并且该请求将“崩溃”,没有任何机会。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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