1

enter image description here

The above error appeared on a browser page, and it says:

Parser Error Message: 'CreatingNetTutorial._default' is not allowed here because it does not extend class 'System.Web.UI.Page'.

I'm an EF newbie trying out EF. Here is the beginnings of my main code:

namespace CreatingNetTutorial.Model
{
    public partial class _default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Book myBook = new Book()
            {
                BookTitle = "Harry Potter",
                Date = DateTime.Now,
                Year = 2005
            };

            BookDbContext db = new BookDbContext();
            db.Books.Add(myBook);

            db.SaveChanges();
        }
    }

My .aspx which contains basically nothing except the first line, which the message complains about:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="CreatingNetTutorial._default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

My code includes EF, and I'm writing it to create a database and store data on it, but haven't created tables on it yet. This runs fine except for this parsing error, no other errors. What does this message I quoted above mean and how can I fix this?

1 Answers1

1

You need to specify the complete namespace of class _default

CreatingNetTutorial.Model

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="default.aspx.cs" Inherits="CreatingNetTutorial.Model._default" %>

Regards,

Carlos Leyva
  • 101
  • 2