Reputation: 1956
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
Have read similar problem posts and solution was to set output path to bin\, but it is defalut for my project.
Upvotes: 29
Views: 325262
Reputation: 8590
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.
Upvotes: 47
Reputation: 505
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.
Upvotes: 12
Reputation: 11
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 ..
Upvotes: -1
Reputation: 313
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#" %>
Upvotes: 0
Reputation: 559
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.
Upvotes: 2
Reputation: 119
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.
Upvotes: 0
Reputation: 5306
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=\"Web\" /optionInfer+" />
</compilers>-->
</system.codedom>
Upvotes: 0
Reputation: 6159
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".
Upvotes: 4
Reputation: 745
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>
Upvotes: 0
Reputation: 296
Sometimes it happens if you either:
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.
Upvotes: 7
Reputation: 1
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.
Upvotes: 0
Reputation: 2784
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.
Upvotes: 2
Reputation: 1201
Try changing CodeBehind="Default.aspx.cs"
to CodeFile="Default.aspx.cs"
Upvotes: 11
Reputation: 253
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.
Upvotes: -1
Reputation: 3712
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:
Upvotes: -3
Reputation: 1
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
Upvotes: 0
Reputation: 1956
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/
Upvotes: 3