Net Core Project Rights Management System (0)

Source: Internet
Author: User

0

Http://www.cnblogs.com/fonour/p/5848933.html

The best way to learn is to do it, and here to develop an ordinary access management system to experience and learn asp. net Core from Zero. The overall planning of the project is broadly as Follows:

Technical Route

    • asp. Net Core MVC
    • Entityframeworkcore
    • Bootstrap Adminlte
    • PostgreSQL

Implementation features

    • Management of organizational structures
    • Role management
    • User Management
    • Functional management
    • Rights Management
1 Development Environment Preparation

1, Install visual Studio 2015, I installed here is the professional Version.

2. Install. NET Core sdk-related

You need to install Visual Studio update3 and net Core 1.0.0-vs tooling

2 New Project

Open Visual Studio 2015, Select the project save path, Enter the project name and solution name, and create a new asp. Net core WEB application (. Net core) project.

To better understand some of the asp. I chose the empty template here

Creating a good project is what it looks like.

General description of the relevant files in the solution

    • Wwwroot storing static resources such as Js,css,images
    • Program.cs Application Portal
    • Startup.cs application-related Startup Item configuration, which contains the configureservices and configure two methods that are responsible for the configuration of the service, which is responsible for the configuration of the HTTP request Pipeline.
    • Project.json the project's underlying configuration file

Delete The example page project_readme.html, at this time we directly F5 run the program, interface output helloworld, This is because Stratup.cs

        public void Configure (iapplicationbuilder app, ihostingenvironment env, iloggerfactory loggerfactory)        {            Loggerfactory.addconsole ();            If (env. Isdevelopment ())            {                App. Usedeveloperexceptionpage ();            }            App. Run (async (context) =            {                await Context. Response.writeasync ("Hello world!");}            );        
3 MVC Basic App 3.0 add MVC Dependency Reference

There are two ways to add MVC References.

1 by Project.json

Open the Project.json file, add the MICROSOFT.ASPNETCORE.MVC reference in the dependencies department, and when you type, Visual Studio will have automatic hints, very intimate and Convenient.

"dependencies": {    "Microsoft.NETCore.App": {"      version": "1.0.0",      "type": "platform"    },    " Microsoft.AspNetCore.Diagnostics ":" 1.0.0 ",        " Microsoft.AspNetCore.Server.IISIntegration ":" 1.0.0 ",    " Microsoft.AspNetCore.Server.Kestrel ":" 1.0.0 ",    " Microsoft.Extensions.Logging.Console ":" 1.0.0 ",    " MICROSOFT.ASPNETCORE.MVC ":" 1.0.0 "  },

2 through NuGet

Search MICROSOFT.ASPNETCORE.MVC Add references through the NuGet manager, or enter the command directly in the Package Manager console Install-packages Microsoft . Aspnetcore. MVC can complete the addition of MVC References.

3.1 Adding a Controller

Right-click Add Project folder, name controllers, Right-click Controllers folder, Add a controller named Homecontroller.

3.2 Adding views

Right-click the project to add views folder, Right-click on the View folder to add a home folder, corresponding to the HomeController controller, in the home folder, a new name named index of the File.

Change the contents of index.cshtml to

3.3 Adding MVC service and HTTP request pipeline processing

1 Adding an MVC service

The Configureservices method for modifying Startup.cs is as follows

        public void configureservices (iservicecollection services)        {            services. ADDMVC ();        }

2 adding HTTP request pipeline Processing

The Configure method for modifying Startup.cs is as follows

        public void Configure (iapplicationbuilder app, ihostingenvironment env, iloggerfactory loggerfactory)        {            Loggerfactory.addconsole ();            If (env. Isdevelopment ())            {                App. Usedeveloperexceptionpage ();            }            App. Usemvcwithdefaultroute ();            App. Run (async (context) =            //{            //    await Context. Response.writeasync ("Hello world!");            //});        }

F5 running the program, you can see that you can already follow the MVC default routing mechanism parsing.

4 asp. NET core default two boarding methods

The ASP. NET core application provides both the IIS service and the Kestrel service by default, which means that the asp. net core application can run out of iis, which is also a cross-platform basis. You can see the addition of this service in the Program.cs File.

        public static void Main (string[] Args)        {            var host = new Webhostbuilder ()                . Usekestrel ()                . Usecontentroot (directory.getcurrentdirectory ())                . Useiisintegration ()                . Usestartup<startup> ()                . Build ();            Host. Run ();        }

The default startup options for Visual Studio are IIS Express, which means that we can use the Kestrel service to run our programs in the following two ways, using the IIS service Mode.

1 Select the option of our project name in the startup option of vs, then run F5.

2 at the root of the project folder, hold down the shift key, right-click the "open command Window here" menu and enter the dotnet run Command.

will prompt the application service has started, and the address is http://localhost:5000, we open the browser to enter this address, you can see the page output of our expected results, and the use of the IIS service is the same effect.

You can modify the address of the application in Program.cs by using the Useurls method.

        public static void Main (string[] Args)        {            var host = new Webhostbuilder ()                . Usekestrel ()                . Useurls ("http://localhost:8000")                . Usecontentroot (directory.getcurrentdirectory ())                . Useiisintegration ()                . Usestartup<startup> ()                . Build ();            Host. Run ();        }
Category: asp. Net Core

Net Core Project Rights Management System (0)

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.