locked
How do you organize your code in a solution? RRS feed

  • Question

  • User-1757034084 posted

    Hey everyone.

    In my solution I need to create a slew of user controls... some user controls are simply input forms, others are for displaying data in a list or gridview... some are meant for public use and others are meant for private, authorized user use.

    In my application I have most of my public pages in the root of the directory.  Any pages that need to have authorization are stored in the Private folder.  It is possible that a Public user control could be on a private page, and visa versa... just highly unlikely at this point in our design.

    So, should I...
    1) create a folder at the root of my application called 'UserControls' and then have a 'Private', 'Public' subfolder
    2) create the user controls in the directories where they're going to be used, like at the root with all the public pages
    3) create a 'UserControl' folder in each location and drop them all there
    4) create a folder at the root called 'UserControls' and drop them all there without subfolders 

    Tuesday, November 20, 2012 2:31 PM

Answers

  • User-576912550 posted

    1) create a folder at the root of my application called 'UserControls' and then have a 'Private', 'Public' subfolder

    I would suggest to put user control in separate library project and reference that library from your application hence you can re-utilize it in other project.

    In my solution I need to create a slew of user controls... some user controls are simply input forms, others are for displaying data in a list or gridview... some are meant for public use and others are meant for private, authorized user use.

    User control which require user to be user authorized in such user control, I would also suggest to put authorization code in base of private user control. So even if some one put private user control in public page then also it will not render because it is also authorizing internally.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 21, 2012 3:49 AM

All replies

  • User1064403333 posted

    I assume your user controls are .ascx files.

    It is possible that a Public user control could be on a private page, and visa versa

    Having a Public user control in a Private page is fine, so long as your Private page is protected via SSL, and Authorisation.

    However,the vice versa is a concern. You do not want a Private user control on a Public page.

    For example, if your Private user control allows add/delete/update of a record, you do not want the Public page to expose this functionality. So, I would not use Private user copntrols ona a Public page. I wouldn't use it for select i.e. display either. After all, if it is Private it should not be made Public.

    In terms of your folder structure, option 4 should be fine;  i.e. ~/UserControls as long as where you use them in the folder i.e. your, ~/PrivateFolder/ is protected via Authorisation and SSL.

     

    Tuesday, November 20, 2012 11:21 PM
  • User-576912550 posted

    1) create a folder at the root of my application called 'UserControls' and then have a 'Private', 'Public' subfolder

    I would suggest to put user control in separate library project and reference that library from your application hence you can re-utilize it in other project.

    In my solution I need to create a slew of user controls... some user controls are simply input forms, others are for displaying data in a list or gridview... some are meant for public use and others are meant for private, authorized user use.

    User control which require user to be user authorized in such user control, I would also suggest to put authorization code in base of private user control. So even if some one put private user control in public page then also it will not render because it is also authorizing internally.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, November 21, 2012 3:49 AM