{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/3991","labels_url":"https://api.github.com/repos/aspnet/Mvc/issues/3991/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Mvc/issues/3991/comments","events_url":"https://api.github.com/repos/aspnet/Mvc/issues/3991/events","html_url":"https://github.com/aspnet/Mvc/issues/3991","id":128749207,"number":3991,"title":"ViewBag breaks app in .NET Core MVC Views on Nano Server","user":{"login":"GuardRex","id":1622880,"avatar_url":"https://avatars.githubusercontent.com/u/1622880?v=3","gravatar_id":"","url":"https://api.github.com/users/GuardRex","html_url":"https://github.com/GuardRex","followers_url":"https://api.github.com/users/GuardRex/followers","following_url":"https://api.github.com/users/GuardRex/following{/other_user}","gists_url":"https://api.github.com/users/GuardRex/gists{/gist_id}","starred_url":"https://api.github.com/users/GuardRex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GuardRex/subscriptions","organizations_url":"https://api.github.com/users/GuardRex/orgs","repos_url":"https://api.github.com/users/GuardRex/repos","events_url":"https://api.github.com/users/GuardRex/events{/privacy}","received_events_url":"https://api.github.com/users/GuardRex/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-26T07:45:39Z","updated_at":"2016-01-26T19:30:39Z","closed_at":null,"body":"Repro: https://github.com/GuardRex/NanoTest\r\n\r\nThis app is configured as an IIS website on Nano Server.\r\n```\r\nc:\\NanoTest\r\n       |____logs\r\n       |____nanotest\r\n                |____ ref\r\n                |____ Views\r\n                |____ wwwroot\r\n                |____ DLL's, `.exe`, etc.\r\n```\r\nViews that don't use `ViewBag` work. `ViewData[\"X\"]` works. `ViewBag.X` breaks with a 502 eventually being returned. It's not the assignment of a value to the `ViewBag` or even necessarily reading the value; it seems to be when the `ViewBag` value is rendered into the markup that it breaks. This does **not** break ...\r\n```html\r\n@{\r\n    ViewBag.Title = \"Nano Test\";\r\n}\r\n<!DOCTYPE html>\r\n<html lang=\"en-US\">\r\n    <head>\r\n        <title>Nano Test</title>\r\n    </head>\r\n...\r\n```\r\n... whereas this **breaks** ...\r\n```html\r\n@{\r\n    ViewBag.Title = \"Nano Test\";\r\n}\r\n<!DOCTYPE html>\r\n<html lang=\"en-US\">\r\n    <head>\r\n        <title>@ViewBag.Title</title>\r\n    </head>\r\n...\r\n```\r\n An exception is not revealed like this ...\r\n```html\r\n@{\r\n    ViewBag.Title = \"Nano Test\";\r\n}\r\n<!DOCTYPE html>\r\n<html lang=\"en-US\">\r\n    <head>\r\n        <title>@{ try { var title = ViewBag.Title; } catch(Exception ex) { Write(ex); } }</title>\r\n    </head>\r\n...\r\n```\r\n... which only yields a 200 response with the page payload like this (thus accessing the value seems ok) ...\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en-US\">\r\n    <head>\r\n        <title></title>\r\n    </head>\r\n...\r\n```\r\nAttempting to `Write` the value, like this ...\r\n```html\r\n@{\r\n    ViewBag.Title = \"Nano Test\";\r\n}\r\n<!DOCTYPE html>\r\n<html lang=\"en-US\">\r\n    <head>\r\n        <title>@{ try { Write(ViewBag.Title); } catch(Exception ex) { Write(ex); } }</title>\r\n    </head>\r\n...\r\n```\r\n... results in the :boom: 502 again.\r\n\r\nBy comparison to `ViewData[\"X\"]`, this works just fine ...\r\n```html\r\n@{\r\n    ViewData[\"Title\"] = \"Nano Test\";\r\n}\r\n<!DOCTYPE html>\r\n<html lang=\"en-US\">\r\n    <head>\r\n        <title>@ViewData[\"Title\"]</title>\r\n    </head>\r\n...\r\n```\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en-US\">\r\n    <head>\r\n        <title>Nano Test</title>\r\n    </head>\r\n...\r\n```\r\nDebug logging for a failed request shows ...\r\n```\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 GET http://pacwuweb001.westus.cloudapp.azure.com:8000/broken  \r\ndbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[4]\r\n      The request path /broken does not match a supported file type\r\ndbug: Microsoft.AspNetCore.Routing.Tree.TreeRouter[1]\r\n      Request successfully matched the route with name '' and template 'broken'.\r\ndbug: Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler[1]\r\n      Executing action PlatformIssue.HomeController.Broken\r\ninfo: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]\r\n      Executing action method PlatformIssue.HomeController.Broken with arguments () - ModelState is Valid'\r\ndbug: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]\r\n      Executed action method PlatformIssue.HomeController.Broken, returned result Microsoft.AspNetCore.Mvc.ViewResult.'\r\ndbug: Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine[1]\r\n      View lookup cache miss for view 'broken' in controller 'Home'.\r\ndbug: Microsoft.AspNetCore.Mvc.Razor.Internal.RazorCompilationService[1]\r\n      Code generation for the Razor file at '/Views/Home/broken.cshtml' started.\r\ndbug: Microsoft.AspNetCore.Mvc.Razor.Internal.RazorCompilationService[2]\r\n      Code generation for the Razor file at '/Views/Home/broken.cshtml' completed in 20.8214ms.\r\ndbug: Microsoft.AspNetCore.Mvc.Razor.Internal.RoslynCompilationService[1]\r\n      Compilation of the generated code for the Razor file at '/Views/Home/broken.cshtml' started.\r\ndbug: Microsoft.AspNetCore.Mvc.Razor.Internal.RoslynCompilationService[2]\r\n      Compilation of the generated code for the Razor file at '/Views/Home/broken.cshtml' completed in 708.1897ms.\r\ndbug: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[2]\r\n      The view 'broken' was found.\r\ninfo: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]\r\n      Executing ViewResult, running view at path /Views/Home/broken.cshtml.\r\ndbug: Microsoft.AspNetCore.Server.Kestrel[6]\r\n      Connection id \"1\" received FIN.\r\n```\r\n... whereas a successful request-response shows this ...\r\n```\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]\r\n      Request starting HTTP/1.1 GET http://pacwuweb001.westus.cloudapp.azure.com:8000/  \r\ndbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[4]\r\n      The request path / does not match a supported file type\r\ndbug: Microsoft.AspNetCore.Routing.Tree.TreeRouter[1]\r\n      Request successfully matched the route with name '' and template ''.\r\ndbug: Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler[1]\r\n      Executing action PlatformIssue.HomeController.Index\r\ninfo: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]\r\n      Executing action method PlatformIssue.HomeController.Index with arguments () - ModelState is Valid'\r\ndbug: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]\r\n      Executed action method PlatformIssue.HomeController.Index, returned result Microsoft.AspNetCore.Mvc.ViewResult.'\r\ndbug: Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine[2]\r\n      View lookup cache hit for view 'Index' in controller 'Home'.\r\ndbug: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[2]\r\n      The view 'Index' was found.\r\ninfo: Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor[1]\r\n      Executing ViewResult, running view at path /Views/Home/Index.cshtml.\r\ninfo: Microsoft.AspNetCore.Mvc.Internal.MvcRouteHandler[2]\r\n      Executed action PlatformIssue.HomeController.Index in 384.9465ms\r\ninfo: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]\r\n      Request finished in 401.4139ms 200 text/html; charset=utf-8\r\ndbug: Microsoft.AspNetCore.Server.Kestrel[9]\r\n      Connection id \"1\" completed keep alive response.\r\n```\r\nThis is not a blocking issue, as `ViewData[\"X\"]` works just fine everywhere. Muchas gracias @davidfowl for helping troubleshoot the problem."},"comment":{"url":"https://api.github.com/repos/aspnet/Mvc/issues/comments/175190627","html_url":"https://github.com/aspnet/Mvc/issues/3991#issuecomment-175190627","issue_url":"https://api.github.com/repos/aspnet/Mvc/issues/3991","id":175190627,"user":{"login":"Eilon","id":202643,"avatar_url":"https://avatars.githubusercontent.com/u/202643?v=3","gravatar_id":"","url":"https://api.github.com/users/Eilon","html_url":"https://github.com/Eilon","followers_url":"https://api.github.com/users/Eilon/followers","following_url":"https://api.github.com/users/Eilon/following{/other_user}","gists_url":"https://api.github.com/users/Eilon/gists{/gist_id}","starred_url":"https://api.github.com/users/Eilon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eilon/subscriptions","organizations_url":"https://api.github.com/users/Eilon/orgs","repos_url":"https://api.github.com/users/Eilon/repos","events_url":"https://api.github.com/users/Eilon/events{/privacy}","received_events_url":"https://api.github.com/users/Eilon/received_events","type":"User","site_admin":false},"created_at":"2016-01-26T19:30:39Z","updated_at":"2016-01-26T19:30:39Z","body":"I wonder if this is the same as https://github.com/dotnet/corefx/issues/5610?"}}