当我尝试构建我的 ASP.NET Core 项目时,我继续在 Visual Studio 2019 中收到此错误消息。当我第二次构建它时,错误消失了。
有谁知道这个错误意味着什么以及如何摆脱它?
谢谢!
<CreateAppHost AppHostSourcePath="$(AppHostSourcePath)"
AppHostDestinationPath="$(AppHostIntermediatePath)"
AppBinaryName="$(AssemblyName)$(TargetExt)"
IntermediateAssembly="@(IntermediateAssembly->'%(FullPath)')"
WindowsGraphicalUserInterface="$(_UseWindowsGraphicalUserInterface)"
Retries="$(CopyRetryCount)"
RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
/>
Run Code Online (Sandbox Code Playgroud)
在我的 Angular 应用程序中,根据登录的用户,我想通过显示/隐藏不同的菜单项或允许/禁止某些路线来授予或限制功能。目前成功登录后,我的 .NET Core API 返回 JWT 令牌以及用户的角色并将其存储在本地存储中。然后我用它来显示我的菜单(例如)。我只是怀疑这是否是最佳实践,因为它暴露了我的用户角色,并且我不确定如果有人在本地存储中手动更改它会发生什么。
有没有更好/更安全的方法来实现这一目标?
如果您需要更多详细信息,请告诉我。谢谢
我在 Visual Studio 2019 中创建了一个 Asp.Net Core 3.1 MVC 项目,然后使用 Angular 9 创建了一个新的 angular 客户端应用程序(遵循本教程)。当我分别运行客户端和服务器时,我能够看到我的 Angular 组件在我的视图中运行。然后我修改了我的 startup.cs 以包含运行 SPA,以便我可以同时运行它们。
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
if (!env.IsDevelopment())
{
app.UseSpaStaticFiles();
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
app.UseSpa(spa =>
{
// …Run Code Online (Sandbox Code Playgroud) 将 DBContext 注入我的存储库时,该using语句应该如何显示?
例如:Startup.cs
services.AddDbContext<VisualDbContext>(options => options.UseSqlServer(Configuration["ConnectionStrings:DefaultConnection"]));
Run Code Online (Sandbox Code Playgroud)
VisualDbContext.cs
public partial class VisualDbContext : DbContext
{
public VisualDbContext(DbContextOptions<VisualDbContext> options) : base(options)
{}
public DbSet<Template> Template { get; set; }
public DbSet<Exercise> Exercise { get; set; }
public DbSet<Symbol> Symbol { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
存储库
public class TemplateRepository : ITemplateRepository
{
private readonly VisualDbContext _dbContext;
public TemplateRepository(VisualDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task<List<KeyValuePair<char, string>>> GetTemplateAsync(int templateId)
{
using (_dbContext) //this seems wrong...
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud) 当我尝试导入 NguCarousel 模块时,我的应用程序因ngModuleType.ngModuleDef未定义而中断。如果我注释掉 NguCarousel 模块的导入,该应用程序可以正常工作。我尝试过更改软件包的版本,但没有成功。目前我已经随 Angular 8 安装了 v1.5.5。
有什么想法为什么这个模块缺少这个属性吗?
包.json
{
"name": "webapi",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run WebApi:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "8.2.12",
"@angular/cdk": "^8.2.3",
"@angular/common": "8.2.12",
"@angular/compiler": "8.2.12",
"@angular/core": "8.2.12",
"@angular/forms": "8.2.12",
"@angular/material": "^8.2.3",
"@angular/platform-browser": "8.2.12",
"@angular/platform-browser-dynamic": "8.2.12",
"@angular/platform-server": "8.2.12",
"@angular/router": "8.2.12",
"@babel/compat-data": "^7.8.0",
"@fortawesome/angular-fontawesome": "^0.5.0",
"@fortawesome/fontawesome-svg-core": "^1.2.28",
"@fortawesome/free-solid-svg-icons": "^5.13.0",
"@ngu/carousel": "^1.5.5",
"@nguniversal/module-map-ngfactory-loader": …Run Code Online (Sandbox Code Playgroud) 当我运行我的 Angular 8 应用程序的 prod 版本时,我在控制台中收到此错误。构建运行良好,我已经在我的提供者中包含了所有服务。
我已经运行了以下命令,但没有收到任何错误。
ng build --prod --optimization=false
有什么办法可以判断什么是失败的?即使我注释掉所有提供程序(预计构建失败),我仍然没有收到任何错误。
请让我知道我可以/应该提供哪些其他信息来帮助您。谢谢!
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule, HTTP_INTERCEPTORS, HttpClient } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { NavMenuComponent } from './nav-menu/nav-menu.component';
//a bunch more components...
import { AccountModule } …Run Code Online (Sandbox Code Playgroud) angular ×3
c# ×2
.net-core ×1
angular-cli ×1
angular9 ×1
asp.net-core ×1
dbcontext ×1
ef-core-3.1 ×1
ng-build ×1
ngu-carousel ×1
npm ×1
roles ×1
typescript ×1