Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 为什么循环在被调用63次后停止?它应该运行到最后,但在63次呼叫后停止90分钟_Asp.net Mvc_Iis_Controller_Limit - Fatal编程技术网

Asp.net mvc 为什么循环在被调用63次后停止?它应该运行到最后,但在63次呼叫后停止90分钟

Asp.net mvc 为什么循环在被调用63次后停止?它应该运行到最后,但在63次呼叫后停止90分钟,asp.net-mvc,iis,controller,limit,Asp.net Mvc,Iis,Controller,Limit,我有一个MVC应用程序,我正在使用它处理XML文件的列表文件夹,我有以下代码: Function Backlog598() 'Dim dir As New DirectoryInfo(Server.MapPath("~/598/")) Dim fileArray As FileInfo() = dir.GetFiles() Dim file As FileInfo Dim fileCounter = 0 For Each file In fileArr

我有一个MVC应用程序,我正在使用它处理XML文件的列表文件夹,我有以下代码:

Function Backlog598()

    'Dim dir As New DirectoryInfo(Server.MapPath("~/598/"))
    Dim fileArray As FileInfo() = dir.GetFiles()
    Dim file As FileInfo
    Dim fileCounter = 0

    For Each file In fileArray

        fileCounter += 1
        Dim i As Integer
        Dim j As Integer

        'Declare Variables for Entity Creation Values
        Dim Var1 = ""
        Dim Var2 = ""
        Dim Var3 = ""
        Dim Var4 = ""
        Dim Var5 = ""
        Dim Var6 = ""
        Dim Var7 = ""

        'Declare Variable for the Message class
        Dim Message = New Message

        'Create a FileStream from the file saved in the MessagesFiles folder
        Dim fs As New FileStream(Server.MapPath("~/598/" + file.Name), FileMode.Open, FileAccess.Read)
        xmlDoc.Load(fs)
        fs.Close()
        xmlNodeList = xmlDoc.GetElementsByTagName("ieXMLDocument")

        'Process the Header Message
        For i = 0 To xmlNodeList.Count - 1
            For j = 0 To xmlNodeList(i).ChildNodes(0).Attributes.Count - 1
                'Set the relevant variable according to the header attributes
                Select Case xmlNodeList(i).ChildNodes(0).Attributes(j).Name
                    Case "Var1" : Var1 = xmlNodeList(i).ChildNodes(0).Attributes(j).Value
                    Case "Var2" : Var2 = xmlNodeList(i).ChildNodes(0).Attributes(j).Value
                    Case "Var3" : Var3 = xmlNodeList(i).ChildNodes(0).Attributes(j).Value
                    Case "Var4" : Var4 = xmlNodeList(i).ChildNodes(0).Attributes(j).Value
                    Case "Var5" : Var5 = xmlNodeList(i).ChildNodes(0).Attributes(j).Value
                    Case "Var6" : Var6 = xmlNodeList(i).ChildNodes(0).Attributes(j).Value
                End Select
            Next
        Next

        'Set the MessageHeader attributes
        marketMessage.CreatedOn = Date.Today
        marketMessage.Var4 = DateTime.Parse(Var4)
        marketMessage.Var2 = Var2
        marketMessage.Var3 = Var3
        marketMessage.Var6 = Var6
        marketMessage.Var1 = Var1
        marketMessage.Var5 = Var5
        marketMessage.fileName = file.Name

        'Add Message class to database context
        db.Messages.Add(Message)
        Try
            db.SaveChanges()
        Catch ex As DbEntityValidationException
            System.Diagnostics.EventLog.WriteEntry("Application", "There were validations errors while attempting to save a Message for the xml file named : " + file.Name, EventLogEntryType.Error)
            For Each validationErrors In ex.EntityValidationErrors
                For Each validationError In validationErrors.ValidationErrors
                    System.Diagnostics.EventLog.WriteEntry("Application", "Message Validation Error : " + validationError.ErrorMessage, EventLogEntryType.Error)
                Next
            Next
        End Try
        Process598(xmlDoc, Message)
        System.IO.File.Delete(Server.MapPath("~/598/" + file.Name)

        If fileCounter = 5 Then
            Return RedirectToAction("Backlog598")
        End If
    Next
    Return Nothing
End Function
这段代码在处理了5个文件并删除了其中的每一个文件后,点击控制器并在文件夹中进行迭代。然后,控制器被调用,就像我让它继续运行一样。由于读取量太大,它变得非常慢,所以我决定这样做

到目前为止,它可以处理63 x 5条记录,总共315条记录,但控制器没有被击中。如果我让它运行一夜,那么它将处理另一组记录。如果我每次保存50条记录,这是我为其他较小的文件所做的,那么它会在停止之前处理3150条记录


这是某种iis或浏览器限制导致无法在所有文件中运行吗?

谷歌Chrome重定向循环错误导致了问题,因为它检测到这是一个无限循环

有人对这可能是由什么引起的有任何建议吗?可能是iis中的“进程回收器”?默认情况下,我相信一个过程会在半夜回收(停止和启动)。为什么要在web应用程序中后台处理文件?为什么不是一个服务或控制台应用程序呢?它只是一个积压的文件web应用程序只是写了一个快速方法来迭代文件夹,但正如我说的,它在63次调用之后停止了。你能计算出它是因为异常停止还是因为它认为它完成了而停止吗?没有异常,它只是停止,然后在大约90分钟后临时重新启动几分钟后,我试着让它运行一夜来处理积压工作,但可以看到文件创建时间,这很好,您返回并用您的答案更新了它。你是怎么发现的?它在什么地方的日志里吗?