Categories
Uncategorized

Side responsive management background of Asp.Net Core MVC and AdminLTE column-based processing

Description:
    .NET Core version: 2.2
    AdminLTE version: 2.4.18
    Bootstrap version: 3.4.1
    font-awesome version: 4.7.0

1、使用VS 2017新建项目:AdminLteDemo,完成后添加区域Admin
在Areas/Admin/Views文件夹添加文件并分别添加如下代码,主要为引用和页面布局使用,这两个文件直接从创建模板里面创建就可以,不用修改名称:
_ViewImports.cshtml

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

_ViewStart.cshtml

@{
    Layout = "_Layout";
}

2, was added in the routing area code Startup class used as the default route management Home address:

app.UseMvc(routes =>
{
     routes.MapRoute(
         name: "areas",
         template: "{area:exists}/{controller=HomeManagement}/{action=Index}/{id?}");
                    
     routes.MapRoute(
          name: "default",
          template: "{controller=Home}/{action=Index}/{id?}");
 });

3, add two controllers Areas / Admin / Contorllers folder
    Home management controller HomeManagementController, remember to add information area, or can not find the content routing code is as follows:

[Area("Admin")]
public class HomeManagementController : Controller
{
    public IActionResult Index()
    {
        return View();
    }
}

Student management controller StudentManagementController, remember to add information area, or can not find the content routing code is as follows:

[Area("Admin")]
public class StudentManagementController : Controller
{
    public IActionResult Index()
    {
        return View();
    }
}

4, corresponding to the view file is added to HomeManagementController, action, code is as follows:

@{
    ViewData["Title"] = "Index";
}

Home Management Index

Adding the action corresponding to StudentManagementController view files, as follows:

@{
    ViewData["Title"] = "Index";
}

Student Management Index

两个视图里面都添加了一个H1标题,已区分不同的内容
5、使用libman添加对adminlte、bootstrap和font-awesome的引用
方法:wwwroot\lib 右键:添加->客户端库

Note: bootstrap 3. * version of the twitter-bootstrap
    As the project comes bootstrap version 4. *, we need to add a reference to the version of the bootstrap 3. *

Add Areas / Admin / Views Shared folder and file _Layout.cshtml added, as follows:




    
    
    
    @ViewBag.Title
    
    
    
    
    

@{
    var controller = (string)ViewContext.RouteData.Values["Controller"];
}

    
@RenderBody()
Copyright © @DateTime.Now.Year All rights reserved.

_Layout.cshtml file AdminLTE and is divided into the following sections:

  1. main-header
  2. main-sidebar
  3. content-wrapper
  4. main-footer

Wherein, 1,2,4 project substantially fixed charge, and 3 is allocated dynamically depending on required permissions, the personnel and adjustment

运行效果图

issues that need resolving:

    Dynamic menu allocation

AdminLTE can hope that a version bootstr 4. * background management framework

My public number

Leave a Reply