Title: Incompatibility with Web API Help Pages (InvalidOperationException: Stack Empty) · Issue #4 · webadvanced/Structuremap.WebAPI2 · GitHub
Open Graph Title: Incompatibility with Web API Help Pages (InvalidOperationException: Stack Empty) · Issue #4 · webadvanced/Structuremap.WebAPI2
X Title: Incompatibility with Web API Help Pages (InvalidOperationException: Stack Empty) · Issue #4 · webadvanced/Structuremap.WebAPI2
Description: I have a Web API project which uses StructureMap for its DI. It's been working fine for awhile, but I'm having some issues with the Web API help pages (Microsoft.AspNet.WebApi.HelpPage) where InvalidOperationExceptions are being thrown a...
Open Graph Description: I have a Web API project which uses StructureMap for its DI. It's been working fine for awhile, but I'm having some issues with the Web API help pages (Microsoft.AspNet.WebApi.HelpPage) where Inval...
X Description: I have a Web API project which uses StructureMap for its DI. It's been working fine for awhile, but I'm having some issues with the Web API help pages (Microsoft.AspNet.WebApi.HelpPage) whe...
Opengraph URL: https://github.com/webadvanced/Structuremap.WebAPI2/issues/4
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incompatibility with Web API Help Pages (InvalidOperationException: Stack Empty)","articleBody":"I have a Web API project which uses StructureMap for its DI. It's been working fine for awhile, but I'm having some issues with the Web API help pages (Microsoft.AspNet.WebApi.HelpPage) where InvalidOperationExceptions are being thrown as a result of an empty stack. \n\nTo test this, I created a new Web API project with the MVC help pages, and it works fine until I add the StructureMap.WebApi2 package, causing the previously mentioned exception to be thrown here, inside ModelDescriptionLink.cshtml when I try to view the documentation for routes involving models which are collections:\n\n```\nelse if (modelDescription is CollectionModelDescription)\n{\n var collectionDescription = modelDescription as CollectionModelDescription;\n var elementDescription = collectionDescription.ElementDescription;\n @:Collection of @Html.DisplayFor(m =\u003e elementDescription.ModelType, \"ModelDescriptionLink\", new { modelDescription = elementDescription })\n}\nelse\n{\n @Html.DisplayFor(m =\u003e modelDescription)\n}\n```\n\nIt's being thrown at `@:Collection of @Html.DisplayFor(m =\u003e elementDescription.ModelType, \"ModelDescriptionLink\", new { modelDescription = elementDescription })` when it tries to display the link to the resource description for his this model.\n\nThis is a slimmed down route that still causes the exception:\n\n```\n[Route(\"Test\")]\npublic IHttpActionResult Post([FromBody] IEnumerable\u003cMySimpleModel\u003e models)\n{\n return null;\n}\n```\n\nAttempting to visit the documentation for this route at `http://localhost:21966/Help/Api/POST-Test` causes the exception:\n\n\n\nI was only able to find one [example of someone having the same problem](https://twitter.com/modul8com/status/492303789899407361) and their solutions were to switch from StructureMap to Ninject or to avoid the exception with null checks. \n\nHere's the top of the stack trace:\n\n```\n[InvalidOperationException: Stack empty.]\nSystem.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52\nSystem.Collections.Generic.Stack`1.Peek() +6693321\nSystem.Web.WebPages.WebPageBase.get_Output() +51\nSystem.Web.WebPages.WebPageBase.GetOutputWriter() +35\nSystem.Web.WebPages.WebPageExecutingBase.BeginContext(String virtualPath, Int32 startPosition, Int32 length, Boolean isLiteral) +50\nASP._Page_Areas_HelpPage_Views_Help_DisplayTemplates_ModelDescriptionLink_cshtml.Execute() in c:...ModelDescriptionLink.cshtml:28\nSystem.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271\nSystem.Web.Mvc.WebViewPage.ExecutePageHierarchy() +122\nSystem.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +145\nSystem.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +695\nSystem.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382\nSystem.Web.Mvc.Html.ActionCacheViewItem.Execute(HtmlHelper html, ViewDataDictionary viewData) +278\n```\n\nBy catching the exception in this place, it pops up later on in `HelpPageApiModel.cshtml` on a nearly identical line: `@Html.DisplayFor(m =\u003e m.ResourceDescription.ModelType, \"ModelDescriptionLink\", new { modelDescription = Model.ResourceDescription })`. This is the top of that stack trace:\n\n```\n[InvalidOperationException: Stack empty.]\nSystem.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52\nSystem.Collections.Generic.Stack`1.Pop() +6667365\nSystem.Web.WebPages.WebPageBase.PopContext() +66\nSystem.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +154\n```\n","author":{"url":"https://github.com/Zajora","@type":"Person","name":"Zajora"},"datePublished":"2015-07-09T14:45:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/4/Structuremap.WebAPI2/issues/4"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:71ad7d0b-3e57-3493-3b93-001460bae042 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9014:B720C:909C3:B81FD:699028AD |
| html-safe-nonce | ff6447cc66df0b84e246630a5ec89e8962c52bb92c645854deb8b558b83f36a1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDE0OkI3MjBDOjkwOUMzOkI4MUZEOjY5OTAyOEFEIiwidmlzaXRvcl9pZCI6IjgyMDI3MzkzMDYzMDcwMDQ1ODkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fad3ed876fbc61dc5a59c5d98bf04ba4296191be31c9a10e1f43cb43739e2820 |
| hovercard-subject-tag | issue:94068169 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/webadvanced/Structuremap.WebAPI2/4/issue_layout |
| twitter:image | https://opengraph.githubassets.com/27e09be1c637385f518c7f1c813578bc72e4d9dae92e1c0a5230b57b733fbc2c/webadvanced/Structuremap.WebAPI2/issues/4 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/27e09be1c637385f518c7f1c813578bc72e4d9dae92e1c0a5230b57b733fbc2c/webadvanced/Structuremap.WebAPI2/issues/4 |
| og:image:alt | I have a Web API project which uses StructureMap for its DI. It's been working fine for awhile, but I'm having some issues with the Web API help pages (Microsoft.AspNet.WebApi.HelpPage) where Inval... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Zajora |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/webadvanced/Structuremap.WebAPI2 git https://github.com/webadvanced/Structuremap.WebAPI2.git |
| octolytics-dimension-user_id | 556018 |
| octolytics-dimension-user_login | webadvanced |
| octolytics-dimension-repository_id | 19080138 |
| octolytics-dimension-repository_nwo | webadvanced/Structuremap.WebAPI2 |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 19080138 |
| octolytics-dimension-repository_network_root_nwo | webadvanced/Structuremap.WebAPI2 |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width