Parser Error: '_Default' is not allowed here because it does not extend class 'System.Web.UI.Page' & MasterType declaration

后端 未结 10 1199
说谎
说谎 2020-12-09 07:22

I recently converted a website project to a web application project in Visual Studio 2008. I finally got it to compile, and the first page (the login screen) displayed as n

相关标签:
10条回答
  • 2020-12-09 07:51

    Look for this:

    ANY page in your project that has a missing, or different Namespace...

    If you have ANY page in your project with <NO Namespace> , OR a

    DIFFERENT Namespace than Default.aspx, you will get this

    "Cannot load Default.aspx", or this: "Default.aspx does not belong here".

    ALSO: If you have a Redirect to a page in your Solution/Project and the page which is to be Redirected To has a bad namespace -- you may not get a compiler error, until you try and run. If the Redirect is removed or commented-out, the error goes away...

    BTW -- What the hell do these error messages mean? Is this MS.Access, with the "misdirection" -- ??

    DGK

    0 讨论(0)
  • 2020-12-09 07:54

    My issue was simple: the Master page and Master.Designer.cs class had the correct Namespace, but the Master.cs class had the wrong namespace.

    0 讨论(0)
  • 2020-12-09 07:59

    I had a similar error but not from a Conversion...

    System.Web.HttpException: 'Namespace.Website.MasterUserPages' is not allowed here because it does not extend class 'System.Web.UI.MasterPage'

    I was also extending the MasterPage class.

    The error was due to a simple compilation error in my Master Page itself:

    System.Web.HttpCompileException: c:\directory\path\Website\MasterUserPages.Master(30): error CS1061: 'ASP.masteruserpages_master' does not contain a definition for 'btnHelp_Click' and no extension method 'btnHelp_Click' accepting a first argument of type 'ASP.masteruserpages_master' could be found (are you missing a using directive or an assembly reference?)

    I was not able to see the error until I moved the MasterPage to the root website folder. Once that was taken care of I was able to put my MasterPage back in the folder I wanted.

    0 讨论(0)
  • 2020-12-09 08:05

    I delete that web page that i want to link with master page from web application,add new web page in project then set the master page(Initially I had copied web page from web site into Web application fro coping that aspx page (I was converting website to web application as project))

    0 讨论(0)
  • 2020-12-09 08:06

    I had copied and renamed the page (aspx/cs). The page name was "mainpage" so the class name at the top of the cs file as follows:

    After renaming the class to match this error was resolved.

    0 讨论(0)
  • 2020-12-09 08:08

    You can always refractor the namespace and it will update all the pages at the same time. Highlight the namespace, right click and select refractor from the drop down menu.

    0 讨论(0)
提交回复
热议问题