We just spent far too long on what turned out to be a stupid problem ... we kept getting an error telling us that the view did not inherit from System.Web.UI.Page ... unfortunately the guy who was working on the particular view and controller could not think of a specific change he had made to cause this error, and looking at the code didn't reveal one either.
The problem was actually quite subtle, and quite stupid ...
A short while before the developer had decided to change the view from being an ".aspx" to being a ".ascx", so removed the view from the solution, added a new view that was a UserControl, and carried on working. What he hadn't done was to actually delete the .aspx file, and even if he had done that, the other developers would have got this weird error too unless they pulled a clean copy of the solution, or manually deleted the files from their disk. (clarification: El Guapo pointed out I was being ambiguous here ... if the file is *deleted* from the *solution* then it will go from disk and from SCM, if if is removed from the solution and then deleted it will remain in other developer's directories *if* a VS addin like Ankh is being used, as the Update will operate against the solution and referenced files, not the folder structure)
When ASP.NET MVC is told to render a view, by using RenderPartial("MyView") or return ("MyView") for example, it goes off merrily and scans the file system for a file matching "MyView.ascx" or "MyView.aspx" (presuming the default ViewEngine) - however if the view exists on disk in both forms, it is a bit of luck as to which actually gets returned and is rendered. Removing the old file fromn the solution is not enough, it still exists on disk - delete the old one and all is well. Hopefully this is a fairly infrequent problem, but it was a real pain to figure out.
So if you get an odd problem in ASP.NET MVC relating to Views ... just make sure you haven't got old files in your directory structure!
09-04-2008 9:27 AM