Are there naming conventions for ASP.NET web appli

2019-08-19 18:31发布

问题:

Currently I am developing a site with about seven partial classes, a few icons, three pages and an App_Themes folder. I was interested to know, is there an industry standard directory structure for anything larger than a small project?

For example, I want to keep the classes in separate folders, the images in separate folders etc. My current directory structure is as follows (not exact, this is from memory):

  • (root) contains the codebehind and forms
  • /App_Data
  • /App_Themes
  • /Bin
  • /Images
  • /Models - I stole the name from MVC. It sounded more appropriate then 'classes'
  • /FusionCharts - a flash charting library

I briefly played with MVC, and it looked like a nice directory structure, however, I am using ASP.NET Ajax.

So, I guess the question is, is there a way to make this directory structure more orderly in your own opinion? Please give answers as to why you made your decision also :).

回答1:

I like to be inspired by Microsoft standards, since we are using a Microsoft technology. Plus a somewhat good standard is better than no standard, especially if you work in a larger team.

App_Code is standard of course, because it has a function in ASP.NET, not just a best practice.

I sort of like the MVC standard project's structure:

  • Content -- Contains subdirectories with Images, Css, Javascript
  • Controllers -- Maybe N/A in WebForms
  • Views -- Also maybe overkill in WebForms

The "Content" folder is maybe the key, since it's the lowest common denominator for ASP.NET projects. So if you work with both WebForms and MVC you'll feel at home in all projects, if you know you have your static resources in that folder.



回答2:

The only "standard" name you are missing for ASP.NET would be App_Code.

Use the convention that makes sense to you and the people that will be maintaining the code. There is no industry standard for this that I've come across in 4+ years of doing ASP.NET development.



回答3:

I also follow the same structure as mentioned by you. The only additions that I make is have separate folders for scripts,CSS, and resources. As far as I am aware of there is no such industry standard.



回答4:

I like having a Content folder under which I can put my Css, Js, and Images folders.



回答5:

Many ASP.Net Web Forms projects will also have a Controls folder for the ASCX controls.

For css styling, we generally use a styles folder, images for image content (sorta an obvious one), js.

You might have a schemas folder, App_Code for ASHX handlers and other types of application code, and a MasterPages folder.

Some auto-created you might see in a Web Forms project are folders are Properties, App_Data, bin, obj, Packages, and TestResults.