VS2015 ASP.NET5 Web Project Structure analysis

Source: Internet
Author: User
Tags website hosting

Objective

1. Open VS2015 New ASP. NET Web Application

2. Select the ASP. 5 Starter Web

3, the new project can be found after the project structure as follows

You can see that the project structure can be divided into 1 to 66 parts. Next I will briefly describe my understanding of these 6 parts.

1, Global.json

1. global.json files are stored in the "solution Items" solution directory, open Global.json file discovery, which is configured by default:

Let's examine the effect of this sources. To do one thing first, download ASP. NET MVC Source address is HTTPS://GITHUB.COM/ASPNET/MVC. Then take a look at the downloaded file

Now I'll simply copy these files to E:\PROJECTS\MVC. Then we go back to Global.json this file, the code is simple to modify, the modified content is as follows

{    ///"Sources": ["src", "test"]    "sources": ["  e:\\projects\\mvc\\src"  ]}

Do two more operations, right-click Solution, First Clean solution solution, second build solution build Solution

After a successful look at what happens to the files under the solution

By tagging, you can see that the solution has loaded the project with the path set in Global.json.

If you want to remove these items, you can restore the sources value in Global.json, and manually delete the project under the solution and recompile.

2, Dependencies (Bower and NPM)

Bower: Bower is a Web package (such as Bootstrap, jquery) managed by Twitter, backed by an increasing number of open source Web (HTML+CSS+JS) projects on GitHub, Bower only requires a GitHub project plus a profile to be managed using the Bower method. Bower provides Web package additions, upgrades, deletions, releases, and Management Pack dependencies, which can be easily managed with a single command, without the need to manually download copy files.

Let's take a look at how bower is used in VS2015. You can first download the installation bower via NuGet.

Then open Bower.json.

Enter Knoc under "dependencies" to find a smart tip amount, I'll show you how to add knockout this JavaScript class library in the future.

But not prompting for the class library version

So I went to the official website http://knockoutjs.com/index.html to enter a version.

" Knockout " " ^3.2.0 "

Next we install it through the menu. First, find the location view==>>others windows==>>task Runner Explorer, open as shown

Then after Tasks==>>bower right click Run, here is actually to check the Bower.json file, and then we add the knockout class library to add to the project, after execution will find

NPM: NPM is a module-dependent management tool for node. js. As a tool used by developers, the main solution is to solve problems when developing node. js. As RubyGems the importance of Ruby developers and Maven for Java developers, NPM is self-evident to developers and communities of node. js. Now that it's been ported to the most invincible development tool in the universe, Visual Studio, it's really exciting.

The corresponding configuration file for NPM in VS2015 is Package.json. Let's add a module: The following can be found, there will also be smart prompt function.

For example, we add the following module

" Express " " ^4.10.2 "

Then you can see it under the NPM folder after executing the task Runner Explorer

You can now right-click Express and then tap the Restore package

It's really about installing the Express module.

For the specific use of NPM, refer to Http://www.infoq.com/cn/articles/msh-using-npm-manage-node.js-dependence

3, References

References: References is actually our previous VS version of the reference, you can look at my VS2010 under the

Unlike before, the VS2015 project directory now has only ASP. NET 5.0 and ASP. NET Core 5.0, where all assemblies are configured to be managed through dependencies nodes in the Project.json file.

Once the reference is saved, the vs2015 will automatically download the corresponding component from NuGet.

4. MVC

Controllers, models, and views are no different from our previous ASP. NET MVC project, migrations is the migration of files using entityframework code in the sample project.

5, seven files

Not in the order.

1, project_readme.html

This page is very simple for a readme HTML page for ASP. NET 5. From this page you can link to the related content page about ASP. NET 5.

2, Startup.cs should be the original Global.asax.cs.

3, Config.json is mainly the configuration database link string.

4, gruntfile.js equivalent to a task plug-in Manager

Here's the grunt task run template.

It is divided into alias tasks and tasks, where the task in alias is Grunt.registertask ("Default", ["Bower:install"]) by registering tasks in Gruntfile.

Tasks are obtained by Grunt.loadnpmtasks ("Grunt-contrib-copy"), which need to be declared in advance through Package.json.

Below, I simply compress a CSS file by grunt.

①, declaring the plug-in in Package.json cssmin

②, loading plugins in the Gruntfile.js file

Grunt.loadnpmtasks ("grunt-contrib-cssmin");

③, installing plugins in NPM

④, refreshing in task Runner Explorer

When the refresh is complete

⑤, adding registration tasks and compressed files in Gruntfile.js

⑥, down to task Runner Explorer to refresh, after refresh

Then execute run

View discovery after execution

But the values are slightly different. It doesn't matter much.

This is just a function of compression performed by Grunt, and there are many other features that are not recorded here.

6, Wwwroot

You may not be a stranger to seeing Wwwroot. Let's see how the website works.

Now click on the Web project right button = = "Publish, select File System

Add app name, select target path, click Publish

Publishing success

Since it has been launched, it is equivalent to the Web site self-hosted success, can now open the site, but what information is not known. Follow the instructions below

Open http://localhost:5000

Summarize

Gruntfile.js manages execution bower and NPM through grunt, and Bower is managed by Bower.json files, and NPM is managed by Package.json.

Project.json is equivalent to the original configuration file that manages the reference collection and other configurations of the project under references.

Startup.cs equivalent to the original Global.asax.cs. Config.json primarily defines the link string for the database.

Wwwroot website hosting can be self-hosted through some configuration.

VS2015 ASP.NET5 Web Project Structure analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.