The 'CodeFile' attribute cannot be used without an 'Inherits' attribute

懵懂的女人 提交于 2021-01-29 10:12:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!