###質問内容
ASPページへのアクセス時、まれに下記のエラーが発生していて困っています。
主にクローラーからアクセスされた際に生じているようです。
間違っています、と言われてもどのパラメーターがどう間違っているのか、アクセスログやコードを追っても検討がつかず・・・
何か糸口があればご教示いただけますと幸いです。
###エラーメッセージ
System.IO.IOException: パラメーターが間違っています
###該当のソースコード
エラーが発生しているソース(ascx.vb)
vb
1 Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load 2 3 Try 4 '記事IDを取得する 5 _strKijiId = _ 6 SanitizedRequest.QueryString(NCommon.CommonConst.QUERY_NAME_id) & "" 7 If _strKijiId.Split("_").Length > 1 Then 8 _strPageString = _strKijiId.Split("_")(1) 9 End If 10 11 Dim result As Integer 12 If _strKijiId = String.Empty _ 13 OrElse _strKijiId.Split("_")(0).Length < 5 _ 14 OrElse Not Int32.TryParse(_strKijiId.Split("_")(0), result) _ 15 OrElse (Not _strPageString = String.Empty AndAlso Not Int32.TryParse(_strPageString, result)) Then 16 17 Call RedirectErrorPage() 18 Exit Sub 19 End If 20 21 '記事データの取得 22 Call GetKijiData() 'エラーの発生箇所 23 24 '(後続の処理は省略) 25 26 Catch ex As Exception 27 comWriteLog.WriteErrorLog(clsLog, clsError, ex, Server, Response, Request, System.Reflection.MethodBase.GetCurrentMethod()) 28 End Try 29 End Sub 30 31 Private Sub GetKijiData() 32 Dim srFile As System.IO.StreamReader = Nothing 33 Dim sr As System.IO.StringReader = Nothing 34 35 Try 36 Dim clsCache As New NCommon.comCache 37 Dim strKeyName As String = GetCacheKey() 38 Dim strKijiData As String = _ 39 clsCache.getCacheItem(strKeyName) 40 41 If strKijiData Is Nothing Then 42 '記事のhtmlファイルが存在しない場合はerror.htmlに遷移 43 Dim objFileInfo As New System.IO.FileInfo(GetKijiFilePath()) 44 If Not objFileInfo.Exists Then 45 Call RedirectErrorPage() 46 Exit Sub 47 End If 48 49 '記事ファイルを読み込む 50 srFile = New System.IO.StreamReader(objFileInfo.FullName) 51 strKijiData = srFile.ReadToEnd() 52 53 '記事をキャッシュする 54 Call clsCache.setCacheItem(strKeyName, strKijiData, CType(Application(NCommon.CommonConst.WEBCONFIG_CACHE_TIME), Integer)) 55 End If 56 57 '記事ファイルを読み込む 58 sr = New System.IO.StringReader(strKijiData) 59 _pArticleHtml = sr.ReadToEnd() 60 61 Catch ex As Exception 62 Throw ex 'イベントログには発生箇所としてここの行数が記載される 63 End Try 64 65 End Sub 66 67 Private Function GetCacheKey() As String 68 If GetDeviceMode() = DeviceMode.PC Then 69 Return NCommon.CommonConst.CACHE_NAME_SAFIX_PC & _strKijiId 70 Else 71 Return NCommon.CommonConst.CACHE_NAME_SAFIX_SP & _strKijiId 72 End If 73 End Function 74 75 Private Function GetKijiFilePath() As String 76 If GetDeviceMode() = DeviceMode.PC Then 77 Return Application(NCommon.CommonConst.WEBCONFIG_KIJI_PC_HTML_PATH) & _strKijiId & NCommon.CommonConst.EXTENSION_HTML 78 Else 79 Return Application(NCommon.CommonConst.WEBCONFIG_KIJI_SP_HTML_PATH) & _strKijiId & NCommon.CommonConst.EXTENSION_HTML 80 End If 81 End Function
comCacheクラス
vb
1 2 Public Function getCacheItem(ByVal strKey As String) As Object 3 4 Return HttpContext.Current.Cache.Get(strKey) 5 6 End Function 7 8 Public Sub setCacheItem(ByVal strKey As String, ByVal objData As Object, ByVal intSeconds As Int32, ByVal intSlidingSeconds As Int32) 9 10 If (intSlidingSeconds > 0) Then 11 HttpContext.Current.Cache.Insert(strKey, objData, Nothing, DateTime.Now.AddSeconds(intSlidingSeconds), Cache.NoSlidingExpiration) 12 Else 13 HttpContext.Current.Cache.Insert(strKey, objData, Nothing, DateTime.Now.AddSeconds(intSlidingSeconds), Cache.NoSlidingExpiration) 14 End If 15 16 End Sub
【2018/6/1追記】
長らく放置していてすみません。
スタックトレースを追えるようにコード変更して再現待ちしたところ、
srFile = New System.IO.StreamReader(objFileInfo.FullName)
の箇所でエラーになっていることが分かりました。
また、objFileInfo.FullNameには正常な値(業務上載せられないのですが、きちんと実物が存在するパス)が入っていました。
何か分かることがあればお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/08/23 07:14