Wednesday, May 25, 2011

ASP.Net Legacy: CodeBehind vs CodeFile

Just had a couple of hairy weeks with some asp.Net 3.5. We were getting a very irritating
File not found Foobar.aspx.vb error for two pages, and in the end it turned out that the pages were originally migrated for .Net 1.1 and has the page directive
CodeFile, which VS2008 doesnt complain about, but which at runtime gives a horrendous default.aspx.vb file not found error, even though the aspx file should be in the dll.
You should check your page directive and change as follows:

<%@ Page Language="vb" AutoEventWireup="false" CodeFile="Default.aspx.vb" Src="Default.aspx.vb" Inherits="DevNamespace.Default_aspx"%>

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Src="Default.aspx.vb" Inherits="DevNamespace.Default_aspx"%>

Its been a while!

So much to do, so little time