3

I had two FARMS. QA and PROD. Both are identical. 2 WFE / 2 APPSERVERS / 1 SQL BACKEND.

When (in QA) I browse an .aspx page it returns this error:

The attribute 'autoeventwireup' is not allowed in this page.

The same page in the other FARM (PRD) works fine. No error.


The page inside just have this:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RequestListDocumts.aspx.cs" Inherits="PMI.CMA.SitePages.UI.RequestListDocumts, PMI.CMA.SitePages.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e977370abbd36787"%>



in the web.config of this webApplication I have

<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="15" TotalFileDependencies="50" AllowPageLevelTrace="false">
  <PageParserPaths>
    <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" />
  </PageParserPaths>
</SafeMode>


and this

<SafeControl Assembly="PMI.CMA.SitePages.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e977370abbd36787" Namespace="PMI.CMA.SitePages" TypeName="*" Safe="True" SafeAgainstScript="False" />

The code of this, of course, is inside a DLL registered in the GAC.

So, I had spend a week reading and digging in this problem but I didnt have any luck. Has someone had a similar issue? Or could anyone give me a hand to understand what is wrong?
I don't think is a code problem. The solution was deployed in both environment using the same version, and the same procedure using powershell scripts.


Many thanks in advance.!!! Cheers!

4
  • I had retract and uninstall all the solutions. Then redeployed again. The same WSP is working on PRD environment and in QA still not working. I had opened a case with MS but it goes so slowly...
    – Javier
    Commented Aug 16, 2012 at 19:32
  • Definitly is an environment configuration. But I don't know where exactly I am missing the config :(
    – Javier
    Commented Aug 16, 2012 at 19:33
  • 1
    I am suffering from the same problem..can anyone suggest? Commented Mar 28, 2018 at 7:24
  • I am also having this problem. None of the answers were marked as accepted. They did not seem to help in my case either.
    – Dave
    Commented Apr 18, 2018 at 19:27

3 Answers 3

2

My experience (specifically with Master Pages and Page Layouts) is that the issue has 4 intertwining triggers:

  1. Master Pages or Page Layouts are customized/published to the content database
  2. Master Pages or Page Layouts utilize code behind files
  3. Master Pages or Page Layouts do have AutoEventWireup="true" in the <%@ Master %> or <%@ Page %> directive
  4. Each Master Page or Page Layout utilizing a code behind must be registered as a SafeControl

I suspect your issue starts with a master page or page layout that is customized or published to the content database in QA, but not in PROD.

The issue essentially does not occur if layouts or master pages are not published to the content database or customized in any way. If anyone has details on why this becomes an issue upon publishing, please inform.

If customization occurred, "Site Settings > Site Actions > Reset to site definition" can be used to undo all customizations, but be sure to read and consider the warning that ALL customizations will be lost.

If layouts or master pages do not require a code behind file, the corresponding AutoEventWireup, CodeBehind, Inherits, etc., attributes can be dropped off the Page/Master directive.

If the layouts or master pages do need a code behind, AutoEventWireup cannot be used, and must be removed from the layout or master. They must also have SafeControl entries for each master page or page layout utilizing a code behind (or, at least utilizing a Type wildcard for the namespace of the code behinds.

2

I had this problem because one of my coworkers had tried to customize the master page in SharePoint Designer. The master was already customized, with code, through Visual Studio, so the existence of a detached copy made SharePoint throw a fit since code isn't allowed on pages inside the content database.

To fix it, I located the offending master page in SharePoint Designer, right clicked, and chose "Reset to site definition."

0

If you get the autoeventwireup is not allowed in this page error, try accessing the page when using a default masterpage that comes with SharePoint vs a customized masterpage.

It has to do with the way SharePoint handles customized pages vs non-customized pages.

Customized pages are presented using a no-code mode handler and therefore can't have server-side code in them. Therefore, autoeventwireup is not allowed.

Uncustomized pages are compiled and can have code in them. So, if you installed the files as a module via a solution package or feature, they are initially non-customized. As long as they are using a non-customized masterpage, they can be compiled.

However, when you use a customized MasterPage with a non-customized page, the page can no longer be compiled as it will use the no-code mode of ASP.Net because of the customized MasterPage.

http://blogs.msmvps.com/windsor/2009/06/21/customized-versus-uncustomized-site-pages-in-sharepoint-2007/

https://support.microsoft.com/en-us/kb/324151

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.