locked
classes in app code folder can't be inherited from? RRS feed

  • Question

  • User297437924 posted

    I have a masterpage in the '/" folder that inherits from a class in the App_Code folder, which in turn inherits from System.Web.UI.MasterPage.

    This used to work in early versions of Visual Studio, but I wrote it a long time ago.   I created a new project with the latest Visual Studio, added all the aspx, master, and vb files from the old project to it, and it won't compile.   

    It seems to be unable to find the code-behind class for the master page when that file is in the app_code folder.

    Is this a bug of the newer Visual Studio?   Is there a workaround?

    Friday, March 13, 2020 6:21 PM

Answers

  • User475983607 posted

    To mgebhard:

    It seems that I created a web-application.   I now looked for alternatives in the new Visual Studio but there aren't any.   If you want to make an asp.net website, it has to be a web-application, unless I'm missing something.

    Are you asking how to create a Web Site project in Visual Studio?

    https://superuser.com/questions/1441880/visual-studio-2019-web-site-template/1476332

    Or you can simply open your existing Web site project in Visual Studio.   You can also open a Web Application in Visual Studio.  It's not clear why you created a new project.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 15, 2020 12:45 PM

All replies

  • User475983607 posted

    RateFor

    Is this a bug of the newer Visual Studio?   Is there a workaround?

    Most likely a bug in your code introduced when moving the files or creating the new project.  Keep in mind, App_Code is used in Web Site projects (dynamically compiled code)  not Web Applications.  What kind of project did you create?

    Edit: https://docs.microsoft.com/en-us/previous-versions/ex526337(v=vs.140)?redirectedfrom=MSDN

    Saturday, March 14, 2020 12:08 PM
  • User297437924 posted

    To mgebhard:

    It seems that I created a web-application.   I now looked for alternatives in the new Visual Studio but there aren't any.   If you want to make an asp.net website, it has to be a web-application, unless I'm missing something.

    Sunday, March 15, 2020 12:31 PM
  • User475983607 posted

    To mgebhard:

    It seems that I created a web-application.   I now looked for alternatives in the new Visual Studio but there aren't any.   If you want to make an asp.net website, it has to be a web-application, unless I'm missing something.

    Are you asking how to create a Web Site project in Visual Studio?

    https://superuser.com/questions/1441880/visual-studio-2019-web-site-template/1476332

    Or you can simply open your existing Web site project in Visual Studio.   You can also open a Web Application in Visual Studio.  It's not clear why you created a new project.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, March 15, 2020 12:45 PM