user7031938 user7031938 - 1 month ago 11
ASP.NET (C#) Question

ASP.net server error in '/' Application Inherits

When I add a webform to my page, I keep getting the error below:
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 'WebApplication9.WebForm11'.

If I remove the Inherits portion it will run. It will also run if I add the inherits portion on one particular reference: Inherits="WebApplication9.GaugePro"

But if I do Inherits on anything else it will error out. Any idea what I did wrong. This just started happening....

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm11.aspx.cs" Inherits="WebApplication9.WebForm11" %>

<!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>

Answer

Just try changing the CodeBehind to CodeFile as follows:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebForm11.aspx.cs" Inherits="WebApplication9.WebForm11" %>

It may occurs in another case also, when you create web application project, then the directive should be:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm11.aspx.cs" Inherits="WebApplication9.WebForm11" %>

For the website project, the first one should work fine.