小编Rez*_*eza的帖子

如何修复npm UNMET PEER DEPENDENCY警告?

我在Windows 10上,使用Node 5.6.0和npm 3.6.0.我正在尝试将angular-material和mdi安装到我的工作文件夹中.npm install angular-material mdi错误:

+-- angular@1.5.0

+-- UNMET PEER DEPENDENCY angular-animate@^1.5.0

+-- UNMET PEER DEPENDENCY angular-aria@^1.5.0

+-- angular-material@1.0.6

+-- UNMET PEER DEPENDENCY angular-messages@^1.5.0 `-- mdi@1.4.57

npm WARN enoent ENOENT: no such file or directory, open
'C:\Users\xxxxx\Desktop\ngClassifieds\package.json' 

npm WARN angular-material@1.0.6 requires a peer of
angular-animate@^1.5.0 but none was installed. 

npm WARN angular-material@1.0.6 requires a peer of angular-aria@^1.5.0
but none was installed. 

npm WARN angular-material@1.0.6 requires a peer of
angular-messages@^1.5.0 but none was installed.
Run Code Online (Sandbox Code Playgroud)

如何解决此问题以安装AngularJS Material和MDI?

node.js npm angularjs npm-install angularjs-material

200
推荐指数
7
解决办法
21万
查看次数

调用新的DbContext时DbContextOptions会发生什么?

我没有使用DI,只是想从我的控制器中调用DbContext.我正在努力弄清楚'选项'应该是什么?

ApplicationDbContext.cs

    public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{

    public DbSet<Gig> Gigs { get; set; }
    public DbSet<Genre> Genres { get; set; }


    public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
        : base(options)
    {
    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
        base.OnModelCreating(builder);
        // Customize the ASP.NET Identity model and override the defaults if needed.
        // For example, you can rename the ASP.NET Identity table names and more.
        // Add your customizations after calling base.OnModelCreating(builder);
    }
}
Run Code Online (Sandbox Code Playgroud)

GigsController.cs

    public class GigsController : Controller
{
    private ApplicationDbContext _context; …
Run Code Online (Sandbox Code Playgroud)

entity-framework entity-framework-core asp.net-core

36
推荐指数
3
解决办法
3万
查看次数

在Entity Framework Core中获取当前用户ID的正确方法

关于如何获取当前登录用户的ID,这里有一堆不同的答案可以解决ASP.NET Core的不同RC问题.我想在这里问一个明确的问题.请注意,project.json现在有"Microsoft.AspNetCore.Identity.EntityFrameworkCore":"1.0.0"

使用RC1,您可以执行以下操作:

using Microsoft.AspNet.Identity;
using System.Security.Claims;

User.GetUserId();
Run Code Online (Sandbox Code Playgroud)

但是随着EF Core新发布的第1版,Microsoft.AspNet.Identity不是正确的版本.

有人建议使用UserManager,这对于获取当前登录的用户来说似乎很多:

private Task<ApplicationUser> GetCurrentUserAsync() => _userManager.GetUserAsync(HttpContext.User);

var user = await GetCurrentUserAsync();
var userId = user?.Id;
Run Code Online (Sandbox Code Playgroud)

我发现的另一种方法是:

private readonly UserManager<ApplicationUser> _userManager;
_userManager.GetUserId(User)
Run Code Online (Sandbox Code Playgroud)

使用ASP.NET Core 1 RTM和EF Core 1以及project.json中的以下库,获取当前登录用户的id的正确方法是什么?

"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
Run Code Online (Sandbox Code Playgroud)

asp.net-identity entity-framework-core asp.net-core

18
推荐指数
2
解决办法
1万
查看次数

通过 IP 访问 IISExpress 以获取 asp.net 核心 API

我有一个在 IIS Express 上运行的 asp.net 核心项目。如果我在浏览器中输入 localhost,URL(http://localhost:53142/https://localhost:44374/)有效,但是,如果我输入我的 IPv4 IP 地址(192.168.1.72),它们就不起作用工作。

在此处输入图片说明

并排

在此处输入图片说明

我可以ping 192.168.1.72 地址就好了。

在此处输入图片说明

为什么我不能通过 ip 访问,我该怎么做?

networking iis-express asp.net-core

4
推荐指数
1
解决办法
6593
查看次数

Prism 7 DI 中的 Register、RegisterInstance 与 RegisterSingleton

我正在尝试在 Prism 7 中注册 DI 服务。我发现以下所有方法都有效,哪一个是正确的方法?各自的情况如何?

public class AndroidInitializer : IPlatformInitializer
{
    static OpenAppService openAppService = new OpenAppService();

    public void RegisterTypes(IContainerRegistry containerRegistry)
    {
        containerRegistry.RegisterInstance<IOpenAppService>(openAppService);

        containerRegistry.Register<IFacebookLoginService, FacebookLoginService>();

        containerRegistry.RegisterSingleton<IAppleSignInService, AppleSignInService>();

    }
}
Run Code Online (Sandbox Code Playgroud)

c# prism

4
推荐指数
1
解决办法
6510
查看次数

EF6 DbMigrations.Sql方法等效于Entity Framework Core

有使用SQL命令执行SQL语句的EF Core等效方法吗?例如。我想通过内核中的迁移来“播种”我的数据库,以在UP方法中使用一些默认值:

    public partial class PopulateGenresTable : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        Sql("INSERT INTO Genres (Id, Name) VALUES (1, 'Jazz')");
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {

    }
}
Run Code Online (Sandbox Code Playgroud)

entity-framework asp.net-core

3
推荐指数
1
解决办法
399
查看次数

在子文件夹中组织控制器和视图 - 最佳实践

我正在考虑在ASP.NET Core MVC应用程序中组织我的代码的最佳实践.我有两种类型的用户,医生和护士,最好的做法是在控制器/视图文件夹中的自己的医生和护士子文件夹中组织我的所有医生和护士控制器/视图吗?

控制器:

  • 控制器/医生/ HomeController.cs
  • 控制器/护士/ HomeController.cs

浏览次数:

  • Views/Doctors/Home/Index.cshtml和其他View文件
  • 意见/护士/主页/ Index.cshtml和其他查看文件

原因是因为在每个Doctors/Nurses子文件夹级别,我想拥有自己的_viewstart文件的共享文件夹.

  1. 这种情况有更好的最佳做法吗?
  2. 此外,在我的控制器中,如何进入子文件夹级别查看文件?我找到的唯一方法是明确指定它们:
public string Index()
{
    return View("~/Views/Doctors/Home/Index.cshtml");
}
Run Code Online (Sandbox Code Playgroud)
  1. 如果我希望我的默认路由转到Doctors/HomeController/Index页面,这就是我在startup.cs文件中指定默认路由的方法.它似乎不起作用.
app.UseMvc(routes =>
{
    routes.MapRoute(
      name: "default",
      template: "Doctors/{controller=Home}/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)
  1. 最后,正如我所提到的,我希望_ViewStart.cshtml每个子文件夹都有不同 的内容.这项工作是否可以接受?

asp.net-core-mvc asp.net-core

2
推荐指数
2
解决办法
3095
查看次数