0

I've got a build with a subset of GET requests that work in one environment but not in another. Even weirder, they do work on initial request, but craps out on all subsequent requests. The error returned is this badboy:

The view at '..' must derive from ViewPage, ViewPage<TModel>, ViewUserControl, or ViewUserControl<TModel>.

It seems to be almost certainly assemblies stepping on each other, but I can't get my head wrapped around it. There were changes in bin assemblies (that, in turn, referenced System.Web.Mvc) between builds, but that doesn't explain why one environment works but the other doesn't. I don't see much GAC differences either.

I'm not asking specifically about this error (it generally has to do with out of sync System.Web.Mvc assemblies), but more about the weird behavior I'm seeing.

Why would an initial request succeed, but subsequent requests fail with the above error?

Has anyone else seen behavior similar to this?

kdawg
  • 2,019
  • 21
  • 31
  • Did you implement the custom razor view class? Perhaps you did that in some area but not in the root of the site? – Marko Sep 26 '13 at 17:39
  • Are you specifying a `@model` but then passing `null` to your view? – Brad Christie Sep 26 '13 at 17:40
  • @Marko There is some custom ViewEngine work going on, but it's not constrained to some area of the site. – kdawg Sep 26 '13 at 17:45
  • @BradChristie Nope, nothing like that. Like I said, the exact same code with the exact same GET requests behave differently depending on the server it's running on. It's almost obvious it's an environmental issue, but I can't chase it down. I feel the weird behavior I described in the question is a key insight into the issue, but I'm lost. – kdawg Sep 26 '13 at 17:46
  • @kdawg I added my answer i hope it helps you resolve this issue... – Marko Sep 26 '13 at 18:16

1 Answers1

0

So based on your answer I am assuming that whatever class you wrote to do the custom ViewEngine is not inheriting from ViewPage class which it should. If you wrote your custom implementation of this then this class has to inherit from ViewPage and ViewPage in case the view is strongly typed. For more information look at this article by Phil Haack:

http://haacked.com/archive/2011/02/21/changing-base-type-of-a-razor-view.aspx

Also take a look at this post about the exact same issue:

Getting the error "The view at '~/Views/Page/home.aspx' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>"

Community
  • 1
  • 1
Marko
  • 12,543
  • 10
  • 48
  • 58
  • I appreciate the help and I'll double-check that I'm doing things correctly w/ re: to Haack's post, but none of this explains neither: 1) why it works on one server, but not another, nor 2) why it successfully renders on initial GET request, but then throws an error when you reload. – kdawg Sep 26 '13 at 18:26
  • Oh, and I see no conflicts of assembly versions when using the MvcDiagnostics.aspx page. – kdawg Sep 26 '13 at 18:27
  • In fact, a comparison of the MvcDiagnostics.aspx output after the initial successful request and after the failed request showed no difference between the list of all loaded assemblies. =/ – kdawg Sep 26 '13 at 19:21
  • Actually, I stand corrected. There are minor differences (a handful of what appears to be temporary compiled view assemblies), but no major differences in versions of loaded assemblies. – kdawg Sep 26 '13 at 19:55
  • Then delete the temps and rebuild see if that fixes the issue. – Marko Sep 26 '13 at 20:39