8
votes

When I am running my ASP.NET application I will get an error

Server Error in '/' Application.

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 'WebApp1._Default'.

Source Error:

Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApp1._Default" %> Line 2:
Line 3:

Source File: /Default.aspx Line: 1


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

How can I solve this problem?

6
Update your Question with hosting environment, are you using visual studio?Saar

6 Answers

8
votes

Check your DLL is in the bin folder. (Not bin/debug...).

4
votes

have you set your web app directory as application in IIS?

I have seen this error many times for different reasons.

  1. Check namespace
  2. dependent dll versions
  3. Visual studio clean and compile again.
  4. clean temp asp.net files "Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files"
2
votes

Did you rename the namespace or class name in the code-behind file? Open the code-behind file and verify that the namespace for the page is called WebApp1 and that the class is called _Default, or update the Inherits-attribute in the aspx page header to fit the code-behind.

0
votes

Have you specified your _Default class is under the namespace WebApp1 in Default.aspx.cs file ?

Please check.

0
votes

For me somehow the code-behind file got removed from the project. They showed up with a different icon in the solution explorer. I just had to expand the ASPX line to see the code behind and then right-click and add it to the project.

0
votes

Please try under "Project Settings/Build" set OutputPath to "bin\" not "bin\debug". this was my problem.