ASP.NET
5 Project Structure
1.Solution
Items
3.The project.json File
In previous versions of ASP.NET, the root of the project was typically the root of the web app. If you placed a Default.aspx file in the project root of an early version of ASP.NET, it would load if a request was made to the web application’s root. In later versions of ASP.NET, support for routing was added, making it possible to decouple the locations of files from their corresponding URLs (thus,
- The
global.json
file
is used to configure the solution as a whole. It includes just two
sections,Project
and
SDK by
default.
- Project
:
The
projects
- SDK:
The
sdk
property specifies the version of the DNX (.Net Execution Environment) that Visual Studio will use when opening the solution.
2.
Framework
Target
ASP.NET
5 can target multiple frameworks, allowing the application to be
deployed into different hosting environments. By default,
applications will target the full version of .NET, but they can also
target the .NET
Core.
3.The project.json File
The
project.json
file
is new to ASP.NET 5. It is used to define the project’s server side
dependencies as well as other project-specific information. The
top-level default sections included in project.json
of
the default web project template are highlighted below:
- userSecretsId property contains a value that acts as a unique ID for your web app.
- Version property specifies the current version of the project. You can also specify other metadata about the project such as authors and description.
- Dependencies section refer to an installed NuGet package or to another project. using wildcards to allow dependencies on a major version but automatically pull in minor version updates.
- Commands section allows you to configure commands that can be run from a command line(for instance, launch a web site or run tests).
- Exclude section is used to identify files and folders that should be excluded from builds..
- publishExclude is used to identify content portions of the project that should be excluded when publishing the site (for example, in production).
- Scripts section is used to specify when build automation scripts should run. Visual Studio now has built-in support for running such scripts before and after specified events.
In previous versions of ASP.NET, the root of the project was typically the root of the web app. If you placed a Default.aspx file in the project root of an early version of ASP.NET, it would load if a request was made to the web application’s root. In later versions of ASP.NET, support for routing was added, making it possible to decouple the locations of files from their corresponding URLs (thus,
HomeController
in
the Controllers folder
is able to serve requests made to the root of the site, using a
default route implementation). However, this routing was used only
for ASP.NET-specific application logic, not static files needed by
the client to properly render the resulting page. Resources like
images, script files, and stylesheets were generally still loaded
based on their location within the file structure of the application,
based off of the root of the project.
The
Dependencies
folder
contains two subfolders:
Bower
and
NPM.
These folders correspond to two package managers by the same names,
and they’re used to pull in client-side dependencies and tools
(e.g. Jquery, BootStrap or Gulp).
Expanding
the folders reveals which dependencies are currently managed by each
tool, and the current version being used by the project.
The
References
folder,
shown within Solution
Explorer in
Visual Studio, details the server-side references for the project.
ASP.NET
5 has decomposed its feature set into a variety of modules that can
be individually added to a web app. This allows for lean web apps
that do not import or bring in features they don’t use. When your
ASP.NET app starts, the ASP.NET runtime calls
Configure
in
the Startup
class.
If you create a new ASP.NET web project using the Empty template, you
will find that the Startup.cs
file
has only a couple lines of code. The default Web project’s Startup
class
wires up configuration, MVC, EF, Identity services, logging, routes,
and more. It provides a good example for how to configure the
services used by your ASP.NET app. There are three parts to the
sample startup class: a constructor, ConfigureServices
,
and Configure
.
The Configure
method
is called after ConfigureServices
and
is used to configure middleware.
0 comments:
Post a Comment