问题
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'.

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
{
}
}
}
}
回答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.
回答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.
If you create your application as Website then the Page directive is CodeFile
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.
回答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.
回答4:
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" %>
回答5:
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
回答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!
回答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.
回答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.
回答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.
回答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.
回答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.
回答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 bin\roslyn
. So I stopped IISExpress, deleted the bin
folder and rebuild the project. There were no build warnings and the application worked fine.
回答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!
回答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.
来源:https://stackoverflow.com/questions/23220357/parser-error-message-could-not-load-type-webmarketing