0

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.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
user3741895
  • 41
  • 1
  • 5

2 Answers2

1

Take a look for the output, it will show the real error instead of guess why CodeFile error.

Tony Dong
  • 3,213
  • 1
  • 29
  • 32
  • Your comment was helpful. However, I've fixed the errors in the output window, and I'm still getting that cryptic error. Do you have any clue where to look? thanks. – Pedro Rodrigues Aug 21 '20 at 15:02
  • Another easy way is copy the code to notepad and then delete this file, recreate the file from visual studio, then paste back the code without the top line in html, most time works for me. – Tony Dong Aug 24 '20 at 20:51
0

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.

Curtis White
  • 6,213
  • 12
  • 59
  • 83