【c# – ASP.NET核心 – 自定义AspNetCore.Identity实现不起作用】教程文章相关的互联网学习教程文章

c#-尽管存在,但IntelliSense抱怨缺少Microsoft.AspNetCore软件包【代码】

在我的Blazor应用程序的客户端,IntelliSense抱怨很多Microsoft.AspNetCore软件包,尽管该项目可以编译并运行良好. 我得到很多东西The type or namespace name 'Mvc' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?) The type or namespace name 'Razor' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?) ...像@inject H...

C#-AspNetCore v2.0-在另一个项目中渲染剃刀视图以进行集成测试【代码】

我想为我的Web应用程序编写集成测试.我使用Microsoft.AspNetCore.TestHost.TestServer通过url与控制器进行通信.但是视图无法呈现.作为回应,我收到错误消息:One or more compilation references are missing. Ensure that yourproject is referencing ‘Microsoft.NET.Sdk.Web’ and the‘PreserveCompilationContext’ property is not set to false.在我的.csproj中,我尝试更改Microsoft.NET.Sdk.Web上的project-sdk,并尝试添加<...

c#-类型或名称空间“ OData”在名称空间“ Microsoft.AspNetCore”中不存在【代码】

我正在构建.Net Core OData接口. 我正在尝试使用名称空间“ Microsoft.AspNetCore.OData”,但它引发错误,指出“名称空间“ Microsoft.AspNetCore”中不存在类型或名称空间“ OData”. 另外,我已经下载了软件包“ Microsoft.AspNetCore”. 问题是:1.我可以使用Microsoft.AspNet.OData代替“ Microsoft.AspNetCore.OData”.这会影响我在.net核心中实现OData吗? 谢谢.解决方法:尝试这个:cd C:/temp dotnet new web dotnet add .\...

c#-将现有的Microsoft.AspNet.Identity DB(EF 6)迁移到Microsoft.AspNetCore.Identity(EF Core)

我正在使用Microsoft.AspNet.Identity的应用程序(APS.net MVC).现在,我想将应用程序更新为使用Microsoft.AspNetCore.Identity的APS.net Core.但是,这两种在每种模型中都有一些差异.是否有任何直接方法可以生成与Microsoft.AspNetCore.Identity相关的更改的初始迁移,以便将现有数据库与Asp.net Core身份连接起来?解决方法:关于asp.net core 3.0以及如何将您的数据库迁移到asp.net core身份3.0数据库中,这里有一个完整的explanation...

c#-.net核心AspnetCore剃刀视图因CompilationFailedException而失败【代码】

当我尝试查看我的Razor页面时,得到以下信息fail: Microsoft.AspNetCore.Server.Kestrel[13]Connection id "0HLFVN3H0G8MT", Request id "0HLFVN3H0G8MT:00000001": An unhandled exception was thrown by the application. Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred: jhhodq42.4nm(4,41): error CS0234: The type or namespace name 'Razor' does no...

如何使用Moq aspnetcore C#xUnit模拟ActionContext【代码】

我正在尝试模拟此控制器:public IActionResult List() { Response.Headers.Add("contentRange", "1");Response.Headers.Add("acceptRange", "1");return Ok(); }通过此测试:[Fact] public void when_call_list_should_return_sucess() {//Arrange//Actvar result = _purchaseController.List();//AssertAssert.Equal(200, ((ObjectResult)result).StatusCode); }但是我的HttpContext为空,并且发生错误,我该如何模拟Acti...

c# – AspNetCore 2.0声明总是空的【代码】

我正在努力将DotNet 4.5 MVC / WebAPI应用程序转换为AspNetCore 2.0,我在使我的Cookie身份验证再次运行时遇到了一些麻烦.当我设置cookie并尝试访问安全方法时,我无法到达那里.当我进入匿名方法并检查用户对象时,它是空的 – 没有身份验证类型,没有声明等. 我尽可能地遵循这篇文章:https://docs.microsoft.com/en-us/aspnet/core/security/authentication/cookie?tabs=aspnetcore2x.我没有使用Identity. 我在startup.cs ConfigureS...

c# – ASP.NET核心 – 自定义AspNetCore.Identity实现不起作用【代码】

我正在构建一个完全自定义的AspNetCore.Identity实现,因为我希望TKey全面成为System.Guid.尊敬的我,我已经派出类型…… >角色:IdentityRole< Guid,UserRole,RoleClaim>> RoleClaim:IdentityRoleClaim< Guid>>用户:IdentityUser< Guid,UserClaim,UserRole,UserLogin>> UserClaim:IdentityUserClaim< Guid>> UserLogin:IdentityUserLogin< Guid>> UserRole:IdentityUserRole< Guid>> UserToken:IdentityUserToken< Guid> > Ap...

c# – AspNetCore.Identity中的Google身份验证【代码】

开始玩AspNetCore.Identity,但不能运行简单的例子,总是收到这样的异常:An unhandled exception occurred while processing the request.InvalidOperationException: No authentication handler is configured tohandle the scheme: googleStartup.cspublic void ConfigureServices(IServiceCollection services){// EF servicesservices.AddEntityFramework().AddEntityFrameworkSqlServer().AddDbContext<MyContext>();// Identi...

c# – 警告尝试构建Service Fabric AspNetCore2项目【代码】

使用最新的Service Fabric SDK(5.7.198)和Visual Studio Professional 15.3.1 我只是试图调试或部署aspnetcore2.0无状态服务时遇到问题.除了添加新控制器之外,我在项目创建向导之后没有对项目进行任何更改. 我已经尝试重新安装.Net Core SDK的x64和x86版本.该项目设置为x64.下面是整个.csproj<PropertyGroup><TargetFramework>net461</TargetFramework><RuntimeIdentifier>win10-x64</RuntimeIdentifier><IsServiceFabricServicePr...

c# – AspNetCore无法解析服务【代码】

我正在将Microsoft.AspNetCore.Identity添加到项目中,我得到了InvalidOperationException: Unable to resolve service for type ‘Microsoft.AspNetCore.Identity.SignInManager’1[Web.Security.Entities.IUser’1[System.Int32]]’ while attempting to activate ‘Web.Security.Services.SecurityService’2[Web.Security.Entities.IUser’1[System.Int32],System.Int32]’.例外是邮递员的复制品,它编码了一些符号.这是我的Star...