【问题标题】:How can I edit the razor pages in the ASP.NET Core (3.1) with Angular and Individual Accounts Authentication type?如何使用 Angular 和个人帐户身份验证类型在 ASP.NET Core (3.1) 中编辑剃须刀页面?
【发布时间】:2022-06-30 04:56:56
【问题描述】:

我使用此模板在 Visual Studio 2022 中创建了一个项目:

该模板让我从正常登录和注册页面开始:

如何编辑这些页面以执行添加按钮和更改颜色等操作?

请注意,在此模板中,没有区域文件夹,我只有以下内容:

我尝试添加脚手架,但出现此错误:

我也非常欢迎任何关于学习剃刀页面和使用 Angular 的教程的建议!

【问题讨论】:

  • 这个包和项目的版本冲突,或者和其他包冲突,所以你需要检查你的xxx.csproj文件看看有没有冲突

标签: angular asp.net-core authentication razor


【解决方案1】:

根据@Xinran-Shen 的评论,我将几乎所有的包都更改为相同的版本。

我有一个没有那个版本的包,所以我保持原样。

我的 .CSProj 文件中的 ItemGroup 部分现在如下所示:

此外,对于具有 Angular 和个人帐户身份验证类型配置/设置的 ASP.NET Core (3.1),当您添加身份时,您必须将其留空:

【讨论】:

    【解决方案2】:
    Edit{
    public ActionResult Edit(int id, Hero hero)
        {
            if(hero.Id != id) return View();
            Hero DbHero = _context.hero.Find(id);
    
            if (hero.Img.CheckType("/images"))
            {
                ModelState.AddModelError("Type", "Wrong Type");
            }
            if (hero.Img.CheckSize(1000))
            {
                ModelState.AddModelError("Size", "Wrong Size");
            }
            if (hero.Img != null)
            {
                FileManager.DeleteImg(Path.Combine(_env.WebRootPath, 
    "images", DbHero.ImgUrl));
                DbHero.ImgUrl = 
    hero.Img.SaveImg(Path.Combine(_env.WebRootPath, "admin/Images"));
            }
            DbHero.Title = hero.Title;
            DbHero.SubTitle = hero.SubTitle;
            _context.SaveChanges();
            return RedirectToAction(nameof(Index));
        }
    

    【讨论】:

      猜你喜欢
      • 2020-04-30
      • 2020-11-01
      • 1970-01-01
      • 2020-09-21
      • 2020-07-15
      • 2020-05-06
      • 2020-07-11
      • 2022-03-03
      相关资源
      最近更新 更多