我在部署网络应用程序期间遇到错误。错误的标题是Could not open Source file: Could not find a part of the path
'无法打开源文件:找不到路径的一部分'E:\ARCHIVES\Projects\Main\Jahan.Handicraft\Jahan.Handicraft.Web.Mvc.UmbracoCms.App\obj\Release\AspnetCompileMerge\TempBuildDir\App_Plugins \UmbracoForms\Data\Web.config;\App_Plugins\UmbracoForms\Data\Web.config'.'。
我在我的项目中使用了Umbraco 7.4.3
und ASP.NET MVC
。我想将其部署在本地主机上。
如何从ASP.NET Identity 2.x中的角色中删除用户?关于向用户添加角色没有问题,但是当我想从用户中删除角色时我无法解决.应该提到的是没有异常或错误!
//POST: Admin/User/Edit/5
[AcceptVerbs(HttpVerbs.Post)]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Edit([Bind(Prefix = "")]UserViewModel userViewModel, List<int> availableRoles)
{
if (ModelState.IsValid)
{
List<int> newListOfRolesIDs = availableRoles;
List<int> oldListOfRolesIDs = UserBLL.Instance.GetRolesIDs(userViewModel.Id);
List<int> deletedList;
List<int> addedList;
var haschanged = oldListOfRolesIDs.ChangeTracking(newListOfRolesIDs, out deletedList, out addedList);
using (new EFUnitOfWorkFactory().Create())
{
if (haschanged)
{
UserBLL.Instance.InsertRoles(addedList, userViewModel.Id);
UserBLL.Instance.DeleteRoles(deletedList, userViewModel.Id);
}
await UserBLL.Instance.UpdateAsync(userViewModel);
}
//ArticleBLL.Instance.UpdatePartial(articleViewModel, m => m.Title);
return RedirectToAction("Edit");
}
return View(userViewModel);
}
Run Code Online (Sandbox Code Playgroud)
删除角色方法:
public void DeleteRoles(List<int> deleteList, int? userId)
{
if (userId != null)
{
User user …
Run Code Online (Sandbox Code Playgroud) 当我运行时 dotnet ef migrations add Initial_Identity
,出现此错误:
在类“Program”上调用方法“BuildWebHost”时出错。在没有应用程序服务提供商的情况下继续。错误:GenericArguments 1 , 'Microsoft.AspNetCore.Identity.IdentityRole', on 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9[TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken,TRoleClaim]'s 违反了'TRole' 类型的约束。脚手架操作可能会导致数据丢失。请检查迁移的准确性。
我该如何解决?
这是我的代码:
创业班:
public void ConfigureServices(IServiceCollection services)
{
// some codes
services.AddIdentity<User, IdentityRole>().AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();
}
Run Code Online (Sandbox Code Playgroud)
程序类:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseDefaultServiceProvider(options => options.ValidateScopes = false)
.Build();
}
Run Code Online (Sandbox Code Playgroud)
TemporaryDbContextFactory 类:
public class TemporaryDbContextFactory :
IDesignTimeDbContextFactory<ApplicationDbContext>
{
////////
public ApplicationDbContext CreateDbContext(string[] args)
{
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
IConfigurationRoot …
Run Code Online (Sandbox Code Playgroud) asp.net entity-framework-core asp.net-core-2.0 ef-core-2.0 entity-framework-migrations
我在我的项目中使用了管理部分的模板(引导管理模板),并从中安装了它Bower
,我已经应用了ASP.NET Core 2
.
当我运行项目时,我收到一个错误:
FileError: ' http://localhost:52125/lib/bootstrap-admin-template/public/assets/less/theme.less ' 未找到 (404)
在 theme.less
但是文件 ,theme.less
存在于路径中!!我不知道为什么浏览器无法识别该文件。
为了路由theme.less
我所做的文件:
<link rel="stylesheet/less" type="text/css" href="~/lib/bootstrap-admin-template/public/assets/less/theme.less">
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
在 ViewComponent 中我收到此警告:(我已经使用过ASP.NET Core 2
)
警告 CS1998:此异步方法缺少“等待”运算符,并将同步运行。考虑使用“await”运算符等待非阻塞 API 调用,或使用“await Task.Run(...)”在后台线程上执行 CPU 密集型工作。
我该如何解决?
public class GenericReportViewComponent : ViewComponent
{
public GenericReportViewComponent()
{
}
public async Task<IViewComponentResult> InvokeAsync(GenericReportViewModel model)
{
return View(model);
}
}
Run Code Online (Sandbox Code Playgroud)
更新:
鉴于,我有@await
:
<div class="container">
@await Component.InvokeAsync("GenericReport", new GenericReportViewModel() { })
</div>
Run Code Online (Sandbox Code Playgroud) 我是角度新手。
我怎么解决这个问题?
我已经安装了 AngularCLI: 11.0.7
和 Node:12.18.4
我已经安装了 Angular 路线防护:
ng g guard auth --skip-tests
Run Code Online (Sandbox Code Playgroud)
错误:
错误:src/app/_guards/auth.guard.ts:15:5 - 错误 TS2322:类型 'Observable<true | undefined>' 不可分配给类型'Observable'。输入“布尔值|” undefined' 不可分配给类型'boolean'。类型“未定义”不可分配给类型“布尔”。
Run Code Online (Sandbox Code Playgroud)15 return this.accountService.currentUser$.pipe( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 16 map(user => { ~~~~~~~~~~~~~~~~~~~ ... 19 }) ~~~~~~~~ 20 ) ~~~~~ src/app/_guards/auth.guard.ts:16:11 - error TS7030: Not all code paths return a value. 16 map(user => { ~~~~~~~~~
代码:
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree } from '@angular/router';
import { ToastrService } …
Run Code Online (Sandbox Code Playgroud) 在我的 Node.js 项目中,我使用了 TypeScript。
我想得到userId
结果,jwt.verify()
但我得到了一个错误。
我该如何解决这个问题?(如果我不使用 typescript,就没有问题。)
userService.ts 文件:
在登录方法中我有以下代码:
import jwt from "jsonwebtoken";
// I have defined userId
token = jwt.sign({ userId: userId, email: email }, secretKey, { expiresIn: expiresIn });
Run Code Online (Sandbox Code Playgroud)
检查 auth.ts 文件:
另外在 check-auth 中间件中我有:
import jwt from "jsonwebtoken";
const decodedToken = jwt.verify(token, process.env.SECRET_KEY);
// Property 'userId' does not exist on type 'string | object'.
// Property 'userId' does not exist on type 'string'.ts(2339)
req.userData = { userId: decodedToken.userId }; // I need …
Run Code Online (Sandbox Code Playgroud) 如您所知,ASP.NET MVC中的同一项目中有模型,视图和控制器.但我想从其他人那里获得单独的模型,并在一个单独的项目中创建我的模型(如ClassLibrary项目或任何可能的项目).
我该怎么做?
(我使用EF6和ASP.MVC 4,5和Visual Studio 2013)
运行项目时,遇到这个问题:(我用过asp.net core 3
。)
无法从根提供程序解析范围服务“Microsoft.AspNetCore.Identity.UserManager`1[Alpha.Models.Identity.User]”。
我怎么解决这个问题?
ApplicationDbContext 类:
public class ApplicationDbContext : IdentityDbContext<User, Role, int,
UserClaim, UserRole, UserLogin, RoleClaim, UserToken>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
public static async Task CreateAdminAccount(IServiceProvider
serviceProvider, IConfiguration configuration)
{
UserManager<User> userManager =
serviceProvider.GetRequiredService<UserManager<User>>();
RoleManager<Role> roleManager =
serviceProvider.GetRequiredService<RoleManager<Role>>();
string userName = configuration["Data:AdminUser:Name"];
string email = configuration["Data:AdminUser:Email"];
string password = configuration["Data:AdminUser:Password"];
string role = configuration["Data:AdminUser:Role"];
if (await userManager.FindByNameAsync(userName) == null)
{
if (await roleManager.FindByNameAsync(role) == null)
{
await roleManager.CreateAsync(new Role(role));
}
User user …
Run Code Online (Sandbox Code Playgroud) c# entity-framework-core asp.net-core asp.net-core-identity asp.net-core-3.0
我在作为类库项目的项目之一中安装了System.Configuration.ConfigurationManager -Version 4.7.0,然后在其中添加了 app.config 文件。
我在我的项目中应用了 ASP.NET Core 3.1。
现在我想获得部分的价值。
为此,我是这样做的:
namespace Alpha.Infrastructure.PaginationUtility
{
public class PagingInfo
{
public virtual int DefaultItemsPerPage { get; set; } = int.Parse(System.Configuration.ConfigurationManager.AppSettings["DefaultItemsPerPage"]);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我收到了“ ArgumentNullException: Value cannot be null ”错误!
我怎么解决这个问题?
App.config 文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="DefaultItemsPerPage" value="3"/>
</appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud) asp.net-core ×4
c# ×4
asp.net ×3
asp.net-mvc ×3
angular ×1
async-await ×1
deployment ×1
ef-core-2.0 ×1
entity-framework-migrations ×1
express ×1
html ×1
jwt ×1
less ×1
node.js ×1
razor ×1
typescript ×1
umbraco ×1
umbraco7 ×1