The Code Directory??

Last post 10-29-2004 3:46 PM by SimonCal. 2 replies.

Sort Posts:

  • The Code Directory??

    09-08-2004, 4:26 AM
    • Member
      65 point Member
    • nileshr
    • Member since 09-07-2004, 2:12 AM
    • Posts 13
    The documentation says: -

    "The \Code directory is a new feature that was not available in ASP.NET 1.0 and 1.1. The use of the \Code directory for initial control testing is optional. The main steps in building a server control are the same as in earlier versions."

    Does it implies that: -

    If we put the class files for the control under the "Code" folder then we are not able to add that control to the tool box right? SO one will not be able to drag and drop the control from the tool box.

    Does that means that if one wants to develop some reusable web custom control he should always go for a WebControlLibrary (which builds a .dll assembly) project only? And that putting the controls code under "code" directory is not at all recommended?

  • Re: The Code Directory??

    09-08-2004, 4:45 AM
    • All-Star
      29,644 point All-Star
    • Fredrik N
    • Member since 06-22-2002, 5:03 AM
    • Sweden
    • Posts 5,334
    • TrustedFriends-MVPs
    If you want to create your custom controls into an assembly, which should be distributed among several apps, you should build a class library and not use the \Code folder (this will probable be changed to \Application_Code in beta 2).

    In an early CTP version, the custom controls added to the \Code folder was added to the toolbox automatically, but it seems not to work in Beta 1.

    I should recommend you to do this:

    Only add code that should only belongs to your application into the \Code folder. But be careful, everyone that has administrator privilege can access the code and read it, so be careful what you put into the code. If you want to create class libraries etc for making assemblies reusable or to avoid publishing the source code to the production server, do not use the \Code folder. You can pre-compile all the code in the \code folder including the .aspx pages into assemblies if you don't want to have the code located as files in the \Code folder on the production server.

    I will probably never use the \Code folder, because I would like to have my domains and domain logic into separated class libraries. But every time I need to do changes in my libraries, I need to recompile and distribute the new assemblies, but I will rather do that instead of have my code located as open files on the production server.
    /Fredrik Normén - fredrikn @ twitter

    ASPInsider

    Microsoft MVP, MCSD, MCAD, MCT

    ASPInsiders
    My Blog
  • Re: The Code Directory??

    10-29-2004, 3:46 PM
    • Participant
      1,910 point Participant
    • SimonCal
    • Member since 06-10-2002, 8:43 PM
    • Posts 381
    • AspNetTeam
      Moderator
    The use of the code folder for custom controls I think is a viable option, and yes the controls are not automatically added to the toolbox. It enables a developer to perform quick development scenarios and testing for a control and does allow a developer to easily share that control across the app. Registration for that control is simplified, in that any page level register directive does not need to have the assembly attribute as reuqired in v1. This registration can also be moved to the configuration, so that regular developers do not need to add to every page if desired.

    By adding the control to the toolbox a referencde to the assembly is required, and this would occur on every change of the code directory as the assembly changes.

    To avoid the issue you have on a production server, then this is easily achieved with the precompilation tool (aspnet_compiler) which will allow you to pre-compile an application and push the appliction to a production server that has no source code and no code folder, but would still allow certain page(ASPX markup) changes

    Hope this clarifies.

    Simon
    This posting is provided "AS IS" with no warranties, and confers no rights.
Page 1 of 1 (3 items)