创建项目

我现在安装的是VS2019 企业版,安装的时候使用的密钥是BF8Y8-GN2QH-T84XB-QVY3B-RC4DF,一起放在这里,万一用得上哩。

  • 打开VS,文件按钮->新建->项目

image.png

  • 语言选择为C#,同时选择为ASP.Net Core Web 应用程序,点击下一步。

image.png

  • 填写项目名称,再创建,下面图片中,选择3.1版本,模板选择Web 应用程序,最后点击创建。

image.png

  • 创建完后,项目结构如下。

image.png

安装并应用NewLife.Cube.Core

这里就是我们的重头戏拉,伟大的魔方登场,首先还是要感谢大石头GG拉。

  • 右键点击项目中依赖项->点击管理NuGet程序包->搜索框输入NewLife.Cube.Core,选中搜索结果,点击安装。

image.png

  • Startup.cs文件修改如下。注意更改空间名jsdhh要改成你自己的 ``` using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using NewLife.Cube;

namespace jsdhh { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; }

  1. public IConfiguration Configuration { get; }
  2. // This method gets called by the runtime. Use this method to add services to the container.
  3. public void ConfigureServices(IServiceCollection services)
  4. {
  5. services.AddControllersWithViews(); // 2020-12-26添加
  6. services.AddCube();
  7. }
  8. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  9. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  10. {
  11. app.UseCube(env);
  12. }
  13. }

} ``` 然后我测试生成解决方案,没有报错,按F5,在弹出的IE地址无法显示的后面,加个/admin,成功拉,输入用户名密码admin注意:初始化运行需要下载静态资源和驱动,生成菜单,所以出现异常或者页面样式不对,都是正常现象,稍等或重新运行项目即可。

image.png