简体   繁体   中英

Error parsing attribute on @page directive

I am trying to set a custom property " DisableBrowserCache " on the page directive like so

<%@ Page Language="VB" AutoEventWireup="false"  DisableBrowserCache="True"
 CodeFile="Info-services.aspx.vb" Inherits="Manager_Info_services" %>

This is the inheritance chain

Partial Class Manager_Info_services
Inherits EltApp.ELTPage
'Code
End Class


Namespace EltApp
Public Class ELTPage
    Inherits System.Web.UI.Page

    Public Property DisableBrowserCache() As Boolean
        Get
            Return _DisableBrowserCache
        End Get
        Set(value As Boolean)
            _DisableBrowserCache = value
        End Set
    End Property
End Class End Namespace

As you can see I inherit from a class that inherits from System.Web.UI.Page. This issue is that setting the property on the directive gives me the following error

System.Web.HttpParseException (0x80004005):
    Error parsing attribute 'disablebrowsercache': 
    Type 'System.Web.UI.Page' does not have a public property named 'disablebrowsercache'. 
---> system.Web.HttpParseException (0x80004005): 
    Error parsing attribute 'disablebrowsercache':
    Type 'System.Web.UI.Page' does not have a public property named 'disablebrowsercache'.
---> System.Web.HttpException (0x80004005):
    Error parsing attribute 'disablebrowsercache':
    Type 'System.Web.UI.Page' does not have a public property named 'disablebrowsercache'.
   at System.Web.UI.TemplateParser.ProcessError(String message)
   at System.Web.UI.TemplateControlParser.ProcessUnknownMainDirectiveAttribute(String filter, String attribName, String value)

I have a feeling it's because im not directly inheriting from System.Web.UI.Page in the codebehind file.

That's not the way the Page directive works. You're asking it to understand your derived class even before the page is parsed.

You should put this in the Page_Init() event of Manager_Info_services .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM