Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) Try Dim request As HttpRequest = HttpContext.Current.Request Dim strPath = request.PhysicalPath '禁止訪問ファイルチェック If request.Path.ToLower.IndexOf("web.config") >= 0 _ Or request.Path.ToLower.IndexOf("global.asax") >= 0 Then Response.Redirect("~/ShowError_Forbidden.aspx", True) Exit Sub End If 'ファイルチェック If Common_Func.FileExists_Check(strPath) Then Server.Execute("~/ShowError_App.aspx") Exit Sub Else Response.Redirect("~/ShowError_NotFound.aspx", True) Exit Sub End If Catch ex As Exception writeLog(ex.Message, Common_Declare.cst_ERRFILE_PATH) Finally End Try End Sub 'データーロード非同期のスレッド Private Shared thdJob As System.Threading.Thread 'タスク開始かとうかフラグ Private Shared blnEnd As Boolean = False Private Shared maxLength As Integer = 0 '関数説明: Request開始処理 '作成者: 姚 '作成日付: 2010/09/14 '補足説明: Sub Application_BeginRequest(ByVal source As Object, ByVal e As EventArgs) Dim request As HttpRequest = HttpContext.Current.Request If request.ContentLength > maxLength Then Dim app As HttpApplication = CType(source, HttpApplication) Dim context As HttpContext = app.Context Dim wr As HttpWorkerRequest = CType(context.GetType().GetProperty("WorkerRequest", BindingFlags.Instance Or BindingFlags.NonPublic).GetValue(context, Nothing), HttpWorkerRequest) Dim buffer(65535) As Byte If wr.HasEntityBody Then Dim contentlen As Integer = Convert.ToInt32(wr.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentLength)) buffer = wr.GetPreloadedEntityBody() Dim received As Integer = buffer.Length Dim totalrecv As Integer = received If Not wr.IsEntireEntityBodyIsPreloaded() Then While contentlen - totalrecv >= received received = wr.ReadEntityBody(buffer, buffer.Length) totalrecv += received End While received = wr.ReadEntityBody(buffer, contentlen - totalrecv) End If context.Response.Redirect("~/ShowError_Syori.aspx") End If End If End Sub