问题
I'm new to building .net applications and I have done alot of research on this, I'm trying to publish a series of asp.net web pages and having been researching why the error is appearing and trying several ways to stop the errors. I've come to a dead end..So I get two types of errors which are :
Error 166 The 'CodeFile' attribute cannot be used without an 'Inherits' attribute. C:\Users\Aj\Code\admin\content.aspx 33
and
Error 148 Could not load type 'MasterPage'. C:\Users\Aj\Code\admin\content.aspx 2
The code identified is :
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="content.aspx.vb" Inherits="_content" MasterPageFile="../MasterPage.master" %>
<%@ MasterType TypeName="MasterPage" %>
Key note: This is one of many files which have the same error, and the master page file is in the parent folder.
回答1:
Take a look for the output, it will show the real error instead of guess why CodeFile error.
回答2:
You should look at the difference in Web Application Project vs Web Site Project. In a web application project, you publish the compiled assemblies while in a website project, you publish the source code. It looks like you may be trying to publish the source from a web app project. It is possible, with some work, to convert to a web site project.
Also, try changing your master file link to use ~/ syntax, it may be a path issue.
来源:https://stackoverflow.com/questions/24228184/the-codefile-attribute-cannot-be-used-without-an-inherits-attribute