Parser Error Message: Could not load type ‘webmarketing’

After finishing the web application and publishing it online no matter I try I keep getting the following error, keep in mind that it runs locally as it should…

Parser Error Message: Could not load type ‘webmarketing’.

enter image description here

I ran through that solution though supposedly I’m doing the same as the solution, yet I’m still facing the same issue…

ASP.NET Parser Error Cannot load code behind


Here is the code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace webmarketing
{
    public partial class Masterpage : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string admin = (string)Session["Admin"];
            if (string.IsNullOrEmpty(admin))
            {
                logout.Visible = false;
            }
            else
            {

            }
        }
    }
}

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I had same problem before i just change CodeBehind to CodeFile and it worked.I remember it works in local but i had this problem after uploading.

Method 2

This is normally happening when you copy files from a Web application projects to Website Project.

When you create a Web Application the Page directive is CodeBehind for the web pages.
enter image description here

If you create your application as Website then the Page directive is CodeFile
enter image description here

So if you copy from a Web application to Website the Namespace as well as the page directive will not change automatically, you should do this manually to rectify this error.

Method 3

I had this error message. The problem was my .cs and aspx files were not added to the project. They were in the folder, but were not added. I solved it by adding them to the project (right click, Add). And then after I built the project, it was compiled into a dll in the bin folder. There was no need to change the text from CodeBehind to CodeFile.

Method 4

what i did to solve my problem giving the same message was to go to IIS and check if it is configured as an Application or simply as a virtual directory. The App icon was just a folder icon. So i right clicked it and Manage Virtual directory > Advanced Settings > convert to Application changed the icon of virtual directory to a green earth icon. Of course the app was targeting framework 4.5, so changed App pool to 4.0 from default app pool, which was there earlier. This solved the issue for me.

But some things i did not say, 1. I am running it locally on IIS 6.1. 2. I am accessing with domain credential and not with ‘pass through’ authentication. Hope this helps

Method 5

regarding the Inherits is should reflect the full name space with class name such as x.y.webmarketing, not the class name or the file name. to wrap it up it should look like below

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.Master.cs" Inherits="Lync_Billing.ui.MasterPage" %>

Method 6

If your application works in your local but fails when deployed to the server, then this issue is most likely related to your IIS settings.

To resolve this, Make sure the “Enable 32-Bit application” property of the target Application pool in IIS is set to “TRUE”.
It WORKS!

Method 7

I think you find the problem is you need to update the files in the BIN folder.
When you run the app it recompiles the files in the BIN folder too. Copy those up to the WEB site and that should fix the problem, it did for me. This is especially true if you create a new page that was not already there which was my case.

Method 8

If you are facing this error after Hosting your Website on server make sure that you create the directory And/Or go to Hosting server -> Site Manager -> Application Starting Point ,select the proper path or folder of your uploaded Published Folder.

It resolve my same problem , I hope it will help you also.

Method 9

In case you encounter this during debugging on your Visual Studio running on a 64-bit operating system, and your application is a 32-bit, set your configuration manager to x86 (32 bit). This agrees to the previous answer to the set IIS to enable 32-bit application on 64-bit.

Visual Studio - Configuration Manager on Build

Method 10

Using VS2015, I checked “Delete all existing files prior to publish” under File Publish Options within the “Publish Web” right-click menu option and this problem went away.

Method 11

For me, I rebuild the individual projects and then rebuild the entire solution.
That worked for me somehow.
Simply building the solution may not work.
I think when you “Clean” the solutions that will fix the issue.

Method 12

I’m using “Microsoft.CodeDom.Providers.DotNetCompilerPlatform” version 1.0.8. When rebuilding there was a warning about not being able to copy files into binroslyn. So I stopped IISExpress, deleted the bin folder and rebuild the project. There were no build warnings and the application worked fine.

Method 13

Non of the mentioned answers worked for me.

My error was the same but I made the mistake and published the Debug version and not release, so make sure before Publishing your project, switch to Release, Clean and Rebuild the solution and the build!

enter image description here

Method 14

Note: I was compiling my WebForms pages at build time.

I had aspx files not referenced in the project but were on disk and that was causing the build errors.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x