1

I'm relatively new to ASP.NET (haven't touched it since .NET was first introduced). I'm using Visual Studio Express For Web 2012.

I've created a master page to work with. However, whenever I create a new page, the default value for "inherits" at the top of the page causes the page to not load, with a "could not load type" error.

I haven't even started coding yet, so I'm not sure what it's looking for.

Edit to add:

Top of a new page looks like this:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="Bitfork.login" %>

The generated code behind page:

namespace Bitfork
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
CXL
  • 1,094
  • 2
  • 15
  • 38
  • 2
    Please show the markup – bash.d Aug 13 '13 at 13:25
  • Can you post the exact error you're getting as well? – Jason P Aug 13 '13 at 13:29
  • 3
    Your code looks good for me. Are you compiling the site before trying to access that page? – Claudio Redi Aug 13 '13 at 13:30
  • Have you tried switching to `CodeFile` instead of `CodeBehind`? `CodeBehind` requires the page to be compiled beforehand. – James Aug 13 '13 at 13:33
  • it was indeed that I needed to compile - I'm so used to just saving and then refreshing the page in my browser! Is there a reason to use CodeBehind instead of CodeFile? – CXL Aug 13 '13 at 13:40
  • 1
    @shifuimam well using `CodeBehind` means your web app is pre-compiled before deployment so it's better performance wise, however, restricts you from making changes on-the-fly. – James Aug 13 '13 at 14:03

2 Answers2

1

This issue was caused in my website when I was using CodeBehind property in <%@ Page ..> directive,

As soon as I changed it to :CodeFile , it worked without the need to recompile every time. I guess from ASP.NET 2.0 onwards this is the case for website templates.

What I observed was that [ framework 4 ], when I create website, the <%@ Page ..> directive contains CodeFile. When create WebApplication, then the <%@ Page ..> directive contains: CodeBehind.

This post may be helpful: ASP.Net 3.5/4.0 CodeBehind or CodeFile?

Community
  • 1
  • 1
R.C
  • 10,417
  • 2
  • 35
  • 48
0

Issue resolved - I didn't realize I needed to recompile the page between each page load.

CXL
  • 1,094
  • 2
  • 15
  • 38