28

I've finished simple asp.net web application project, compiled it, and try to test on local IIS. I've create virtual directory, map it with physical directory, then put all necessary files there, including bin folder with all .dll's In the project settings, build section, output path is bin\ So when i try to browse my app i got:

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 'AmeriaTestTask.Default'.

Source Error: 


Line 1:  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AmeriaTestTask.Default" %>
Line 2:  
Line 3:  <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>


Source File: /virtual/default.aspx    Line: 1 

enter image description here

Have read similar problem posts and solution was to set output path to bin\, but it is defalut for my project.

igorGIS
  • 1,888
  • 4
  • 27
  • 41
  • 1
    Parser errors tend to mean that your ASPX pages are not well formed. – Oded Feb 10 '13 at 17:37
  • 1
    Thanks for reply. I've no warnings in VS2010 and from IDE project runs just fine. – igorGIS Feb 10 '13 at 17:40
  • It will. Did you load the page up in your local environment? (dev web server, IIS express or full IIS locally) – Oded Feb 10 '13 at 17:41
  • Yes it is local enviroment, i've workstation Win7 x64 and IIS 7.5 installed – igorGIS Feb 10 '13 at 17:43
  • 1
    Look at the ASPX. Make sure the markup is all valid - that it is good XML. – Oded Feb 10 '13 at 17:43
  • Default.aspx is valid XHTML 1.1, one solution that works is to place bin folder one level up (have googled) but it is ugly and i want to understand why it not work as it should. – igorGIS Feb 10 '13 at 17:47
  • Are you sure the web application has been setup correctly? – Oded Feb 10 '13 at 17:50
  • 1. I've create physical folder C:\ameria\root, then in ISS manager 've create virtual directory 'virtual' and map it with those path, then copied all .aspx files, web.config, styles and bin folder there. Application pool is ASP.NET v4.0 Classic, target platform v.4.0 – igorGIS Feb 10 '13 at 17:54
  • I just solved this issue as I was going through with solutions. Create another Master file and link it and see. As well, simple thing like rebuilding solution will do the trick as well, if you use a custom URL using IIS. – silvachathura Apr 18 '21 at 21:18

17 Answers17

46

I know i am too late to answer but it could help others and save time.

Following might be other solutions.

Solution 1: See Creating a Virtual Directory for Your Application for detailed instructions on creating a virtual directory for your application.

Solution 2: Your application’s Bin folder is missing or the application’s DLL file is missing. See Copying Your Application Files to a Production Server for detailed instructions.

Solution 3: You may have deployed to the web root folder, but have not changed some of the settings in the Web.config file. See Deploying to web root for detailed instructions.

In my case Solution 2 works, while deploying to server some DLL's from bin directory has not been uploaded to server successfully. I have re-upload all DLL's again and it works!!

Here is the reference link to solve asp.net parser error.

immayankmodi
  • 8,210
  • 9
  • 38
  • 55
11

I had the same issue. Ran 5 or 6 hours of researches. A simple solution seems to be working. I just had to convert my folder to application from iis. It worked fine. (this was a scenario where I had done a migration from server 2003 to server 2008 R2)

(1) Open IIS and select the website and the appropriate folder that needs to be converted. Right-click and select Convert to Application.

enter image description here

Aravinda
  • 495
  • 1
  • 7
  • 17
  • 1
    worked for me too. Thanks. For all the other people facing this problem and trying this solution, please copy all the code from the old global.asax exactly and paste it in the new global.asax file as it is. For those, who don't know how to add a global.asax in your project, directions are given on this link: http://stackoverflow.com/questions/21346969/how-to-add-global-asax-file-to-asp-net-mvc4-project But please again, make sure you copy the code from the old global.asax exactly as it to new global.asax and it should then work. Goodluck. – Jogi Feb 02 '17 at 05:01
  • It worked, but I don't understand how does it work. Please explain.Your link is not working. – Junaid Pathan Jun 18 '19 at 14:26
  • Site works again. I think its like adding a separate folder will not create the execution environment. IIS will treat it as just a folder. ones you turn the folder into, application it will enable execution using application pools. such as .net/c# environment etc. anyway , to me it was a misleading message! – Aravinda Jun 19 '19 at 00:01
9

Try changing CodeBehind="Default.aspx.cs" to CodeFile="Default.aspx.cs"

Codeone
  • 1,173
  • 2
  • 15
  • 40
7

Sometimes it happens if you either:

  1. Clean solution/build or,
  2. Rebuild solution/build.

If it 'suddenly' happens after such, and your code has build-time errors then try fixing those errors first.

What happens is that as your solution is built, DLL files are created and stored in the projects bin folder. If there is an error in your code during build-time, the DLL files aren't created properly which brings up an error.

A 'quick fix' would be to fix all your errors or comment them out (if they wont affect other web pages.) then rebuild project/solution

If this doesn't work then try changing: CodeBehind="blahblahblah.aspx.cs"

to: CodeFile="blahblahblah.aspx.cs"

Note: Change "blahblahblah" to the pages real name.

4

I've solve the issue. The solution is to not making virtual dir manualy and then copy app files here, but use 'Add Application...' option. Here is post that helped me http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/7ad2acb0-42ca-4ee8-9161-681689b60dda/

igorGIS
  • 1,888
  • 4
  • 27
  • 41
4

I have solved it this way.

Go to your project file let's say project/name/bin and delete everything within the bin folder. (this will then give you another error which you can solve this way)

then in your visual studio right click project's References folder, to open NuGet Package Manager.

Go to browse and install "DotNetCompilerPlatform".

Mo D Genesis
  • 5,187
  • 1
  • 21
  • 32
2

Faced the same error when I had a programming error in one of the ASHX files: it was created by copying another file, and inherited its class name in the code behind statement. There was no error when all ASPX and ASHX files ran in IIS Express locally, but once deployed to the server they stopped working (all of them).

Once I found that one ASHX page and fixed the class name to reflect its own class name, all ASPX and ASHX files started working fine in IIS.

ajeh
  • 2,652
  • 2
  • 34
  • 65
1

Very old question here, but I ran into the same error and none of the provided answers solved the issue.

My issue occurred because I manually changed the namespace and assembly names of the project after initial creation. Took me a little bit to notice that the namespace in the Inherits attribute didn't match the updated namespace.

Updating that namespace in the Global.asax markup to match the apps namespace fixed the error for me.

A-A-ron
  • 529
  • 1
  • 5
  • 14
0

IIS 7 or IIS 8 or 8.5 version - if you are migrating from 2003 to 2012/2008 make sure web service are in application type instead virtual directory

0

In my case, There were new code branch and old code branch was deployed locally in IIS. So it was pointing to old branch code that was not available. So i had deployed my code to IIS with new branch and it is working now.

Jeetendra
  • 1
  • 1
0

In my case I missed the compile tag in the .csproj file

<Compile Include="Global.asax.cs">
  <DependentUpon>Global.asax</DependentUpon>
  <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
David
  • 703
  • 11
  • 24
0

Interesting all the different scenarios..

In my case...I had uploaded my site to GoDaddy and was getting the Parser Error.

I resolved it by commenting out compilers under system.codedom in web.config. And also add a custom profile for publishing that would precompile during publishing.

  <system.codedom>
    <!--GoDaddy does not compile!-->
    <!--<compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>-->
  </system.codedom>
Chris Catignani
  • 5,040
  • 16
  • 42
  • 49
0

When you add subfolders and files in subfolders the DLL files in Bin folder also may have changed. When I uploaded the updated DLL file in Bin folder it solved the issue. Thanks to Mayank Modi who suggested that or hinted that.

Sam Patirage
  • 109
  • 5
0

Looking at the error message, part of the code of your Default.aspx is :

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

but AmeriaTestTask.Default does not exists, so you have to change it, most probably to the class defined in Default.aspx.cs. For example for web api aplications, the class defined in Global.asax.cs is : public class WebApiApplication : System.Web.HttpApplication and in the asax page you have :

<%@ Application Codebehind="Global.asax.cs" Inherits="MyProject.WebApiApplication" Language="C#" %>
Mario
  • 313
  • 2
  • 11
-1

I am too late but let me explain how I solved this problem.

This problem is basically because of improper folders/solution structure.

this issue may occur because 1. If you have copied project from other location and trying to run the project.

so to resolve this go to original location and crosscheck the folders and files again.

this works for me.

-1

After a lot of searching ,i found the problem was in my project dll file .i cleaned and rebuild my project when there were compilation errors ... simple solution is to remove all compilation errors in all pages either by removing contents or commenting lines ,then clean and rebuild your project ... this will sort out your problem ..

-3

This happens when the files inside the Debug and Release folder are not created properly(Either they are having wrong reference or having overwritten many times). I have faced the same problem in which, i everything works fine when we build the solution, but when i publish the website it gives me same error. I have solved this in following manner:

  1. Go to your Solution Explorer in Visual Studio and click on show hidden files (if they are not showing ! )
  2. you will find a folder named obj, open it .
  3. Here there are again 2 folder named respectively as Debug and Release. Now, delete the content from these two folder, Make sure that you do not delete the folders Debug and Release. Only delete the files and folders inside Debug and Release folder.
  4. Now build and publish your solution and everything will work like charm.
Roshan Parmar
  • 3,692
  • 1
  • 11
  • 7