StevieB StevieB - 1 year ago 126
ASP.NET (C#) Question

ASP.NET Parser Error Cannot load code behind

Hey I am getting the following error

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type '_AddToCart'.

Source Error:

Line 1: <%@ Page Language="C#" AutoEventWireup="true" Codebehind="AddToCart.aspx.cs" Inherits="_AddToCart" Title="Untitled Page" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

Source File: /FSAICart/AddToCart.aspx Line: 1

Where I do have the matching code behind file which is defined as follows

using System;
public partial class _AddToCart : System.Web.UI.Page {

Any Ideas ?

Answer Source

Specify the namespace of the Inherits property of Page directive

Look at codebehind of your page. It looks like:

namespace MyWebSite
     public partial class _AddToCart : System.Web.UI.Page 

So you must change Page directive to:

<%@ Page Language="C#" AutoEventWireup="true" Codebehind="AddToCart.aspx.cs" Inherits="MyWebSite._AddToCart" Title="Untitled Page" %>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download