AsP.NetコアUseStatusCodePagesWithReExecute()
、私は/StatusCode/{0}
にリダイレクトします。私は以前に任意のapparant問題なくUseStatusCodePagesWithRedirect()
を使用していたが、変化することから、以前に今リダイレクトされた要求は、未処理の例外が発生:UseStatusCodePagesWithReExecute未処理例外重複キー:System.Object
ArgumentExceptionが:同じキーを持つ項目が既に追加されています。キー:System.Objectの
はここVS15のデバッグウィンドウからの出力です:
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:5000/guides/some-guide/introdu
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method WebSite.Controllers.GuideController.ReadSection (WebSite) with arguments (some-guide, introdu) - ModelState is Valid
Microsoft.EntityFrameworkCore.Storage.IRelationalCommandBuilderFactory:Information: Executed DbCommand (0ms) [Parameters=[@__permalink_0='?' (Size = 450)], CommandType='Text', CommandTimeout='30']
SELECT TOP(2) [s].[SectionId], [s].[Description], [s].[DisplayPosition], [s].[DocumentId], [s].[Permalink], [s].[Title], [d].[DocumentId], [d].[CategoryId], [d].[Description], [d].[DisplayPosition], [d].[Permalink], [d].[Subtitle], [d].[Title]
FROM [Sections] AS [s]
INNER JOIN [Documents] AS [d] ON [s].[DocumentId] = [d].[DocumentId]
WHERE [s].[Permalink] = @__permalink_0
ORDER BY [s].[SectionId]
Microsoft.AspNetCore.Mvc.StatusCodeResult:Information: Executing HttpStatusCodeResult, setting HTTP status code 404
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action WebSite.Controllers.GuideController.ReadSection (WebSite) in 15.6192ms
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method WebSite.Controllers.ErrorController.StatusCode (WebSite) with arguments (404) - ModelState is Valid
WebSite.Controllers.ErrorController:Information: Unexpected Status Code: 404, OriginalPath: /guides/some-guide/introdu
'dotnet.exe' (CoreCLR: clrhost): Loaded 'g4tz3vmn.35h'. Cannot find or open the PDB file.
Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor:Information: Executing ViewResult, running view at path /Views/Error/Index.cshtml.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action WebSite.Controllers.ErrorController.StatusCode (WebSite) in 86.9564ms
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Users\Me\.nuget\packages\System.Diagnostics.StackTrace\4.3.0\lib\netstandard1.3\System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.0\System.IO.MemoryMappedFiles.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'dotnet.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.1.0\System.IO.UnmanagedMemoryStream.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware:Error: An unhandled exception has occurred while executing the request
System.ArgumentException: An item with the same key has already been added. Key: System.Object
at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(Object key)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeAsync>d__20.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at WebMarkupMin.AspNetCore1.WebMarkupMinMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.<>c__DisplayClass6_0.<<UseStatusCodePagesWithReExecute>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Web.BrowserLink.Runtime.BrowserLinkMiddleware.<ExecuteWithFilter>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 342.116ms 500 text/html; charset=utf-8
それは私が、BAM、その後、私のStatusCodeコントローラアクション罰金を実行し、エラーの元のパスをログインしているように見えます例外を取得します。このエラーの原因は何ですか?
私はそれを分解しようとしていますが、私はそれを指している辞書を探すのに苦労しています。すべてのインスタンスでエラーが発生することはありません。パスの要素を使用してデータベースレコードを取得している場合のみです。ミスペルトまたは存在しないコントローラとアクションは、それらのインスタンスで期待通りに動作します。データベースに問題が発生したことを照会するときだけです。明示的な辞書がないので、それはEFと関係がありますか?私はまだ例外をスローする呼び出しを見つける必要があります。 –
スタック全体をすばやく見ているうちに、次のことに気付きました。同じキーを持つアイテムが既に追加されています。このエラーはINSERTに関連しているようです。あなたはEFに関連することについて言及して以来、例外を受けているのは、そうかもしれません。 Btw ...一見すると、あなたがしていると思われるエラーは、あなたの投稿のタイトルとは関係ありません。 – Vlince
ヴィンスさん、ありがとうございました。もうちょっと掘り下げて、私が何を思いつくのか見てみましょう。リダイレクトを使ってステータスコードページから変更したときにエラーが発生しただけなので、私はその投稿をそのままタイトルにしました。私は問題のより良い対処をしたら、私は名前を変更します。 –