Web Application Project and App_code folder...

Last post 08-19-2008 1:15 PM by black_russian. 5 replies.

Sort Posts:

  • Web Application Project and App_code folder...

    06-03-2008, 11:57 AM
    • Member
      372 point Member
    • Nuwanda
    • Member since 09-25-2007, 3:42 PM
    • Posts 207

    I'm using a web application project but also...in it I have an app_code folder ....there I  have a couple of classes..........is this bad? should I store the helper classes in an ordinary folder?

    Any comments appriciated.

     Nuwanda

    You learn from experience, everything else is just information.
  • Re: Web Application Project and App_code folder...

    06-03-2008, 12:22 PM
    • All-Star
      20,998 point All-Star
    • Jeev
    • Member since 11-24-2005, 12:49 PM
    • Posts 3,163

     I would move those classes to a class library project and then add the reference to that project in your web application project

    Jeev
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If you get the answer to your question, please mark it as the answer.
  • Re: Web Application Project and App_code folder...

    06-03-2008, 3:43 PM
    • Member
      372 point Member
    • Nuwanda
    • Member since 09-25-2007, 3:42 PM
    • Posts 207

    Thank you for the reply Jeev.

     Why would you do that? How does the WAP model handle the special app_code directory...why is it even possible to have it in wap? Dynamic compiling in the website model makes sense...but what does it do, if anything, in wap?

     

    You learn from experience, everything else is just information.
  • Re: Web Application Project and App_code folder...

    06-03-2008, 3:50 PM
    Answer
    • All-Star
      20,998 point All-Star
    • Jeev
    • Member since 11-24-2005, 12:49 PM
    • Posts 3,163

    2 main reasons why we do so

    1. In a big project having multiple files in the app_code slows down the IDE since it has to dynamically compile the classes inside the folder(if you use a website model)

    2. to promote reuse.. we share the BLL and DAL across projects , hence having it as a separate projects / DLL's uncoupled from the web project promotes reuse 

    As far as I know Web application projects do not dynamically compile classes in the App_code folder only web site projects do so


    Jeev
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If you get the answer to your question, please mark it as the answer.
  • Re: Web Application Project and App_code folder...

    06-03-2008, 9:07 PM
    • Member
      372 point Member
    • Nuwanda
    • Member since 09-25-2007, 3:42 PM
    • Posts 207

    Thanx Jeev, both valid points.......I just found some comments from scottgu, seems like the WAP project does dynamically compile stuff after all.  I have a couple of classes in an app_code dir in a WAP project......."Rename that folder, I must" :)

    VERY, VERY IMPORTANT: Because ASP.NET 2.0 tries to dynamically compile any classes it finds under the /App_Code directory of an application at runtime, you explictly *DO NOT* want to store classes that you compile as part of your VS 2005 Web Application Project under an "app_code" folder. If you do this, then the class will get compiled twice -- once as part of the VS 2005 Web Application Project assembly, and then again at runtime by ASP.NET. The result will most likely be a "could not load type" runtime exception -- caused because you have duplicate type names in your application. Instead, you should store your class files in any other directory of your project other than one named "app_code". This will be handled automatically by the "Convert to Web Applicaiton" command. This command will rename the folder Old_App_Code. 

    Nuwanda

    You learn from experience, everything else is just information.
  • Re: Web Application Project and App_code folder...

    08-19-2008, 1:15 PM
    • Member
      2 point Member
    • black_russian
    • Member since 07-10-2007, 1:16 AM
    • Kingston, Jamaica
    • Posts 1

    One observation I made when using the App_Code with a C# Web Application Project is that it does not report errors int eh out put and you poject will compile with out reporting errors, but when you load a page it will display the error and the IDE's error window will show the error.

Page 1 of 1 (6 items)