ASP.NET Core 实现用户登录验证的最低配置

发布于:
Microsoft.Net

网上找的备用。

背景是在一个项目中增加临时登录功能,只需验证用户是否登录即可,所需的最低配置与实现代码如下。

在 Startup 的 ConfigureServices() 方法中添加 Authentication 的配置:

services
    .AddAuthentication(options =>
    {
        options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    })
    .AddCookie();

在 Startup 的 Configure() 方法中将 Authentication 添加到请求管线:

app.UseAuthentication();

在登录程序中验证通过用户名/密码后,通过下面的代码生成登录 Cookie 并发送给客户端:

var claimsIdentity = new ClaimsIdentity(
    new Claim[] { new Claim(ClaimTypes.Name, model.Email) },
    "Basic"
);
var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrincipal);

 

How to enable NTFS Long Paths in Windows 10

发布于:
其他(计算机)服务器技术

解决源文件名长度大于文件系统支持的长度问题

In Windows 10 Anniversary Update, Microsoft finally addressed a long-standing issue that developers faced while doing development – the 260 character limitation for path length. This path length limitation was present in Windows for almost an eternity. In case you don’t know, in all currently released Windows versions, the maximal length of the file path is 260 chars. Starting with build 14352 of Windows 10, which is part of the Anniversary Update (version 1607), this limitation can be bypassed.

All Your Images Are Belong to Umbraco

发布于:
Microsoft.Net

Today I am going to talk to you about a tool that has been shipped within the Umbraco core since v7.1. It powers the Image Cropper property editor but can do much much more to help you build high quality, performant websites. That tool is called ImageProcessor.

ImageProcessor is actually two libraries: ImageProcessor – A library for desktop and web that provides a fluent API allowing you to easily chain methods to deliver the desired output, and ImageProcessor.Web – A web extension to ImageProcessor that allows the developer to perform image manipulation using a Url API of querystring parameters as instructions.

TinyMCE4 file_picker_callback

发布于:
Script

Code for TinyMCE:

tinymce.init({
    file_picker_callback: function (callback, value, meta) {
        myImagePicker(callback, value, meta);
    }
});
function myImagePicker(callback, value, meta) {
    tinymce.activeEditor.windowManager.open({
        title: 'Image Browser',
        url: '/media/browser/1?type=' + meta.filetype,
        width: 800,
        height: 550,
    },
        {
            oninsert: function (url, objVals) {
                callback(url, objVals);
            }
        });
};

微软良心之作——Visual Studio Code 开源免费跨平台代码编辑器

发布于:
Microsoft.Net其他(计算机)

微软 Visual Studio Code 免费跨平台代码编辑器 – 支持多种编程语言与系统

在 Build 2015 大会上,微软除了发布了 Microsoft Edge 浏览器和新的 Windows 10 系统外,最大的惊喜莫过于宣布推出免费跨平台的 Visual Studio Code 编辑器了!


Visual Studio Code 软件截图

ABP 学习 解决:Update-Database : 无法将“Update-Database”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1

发布于:
Microsoft.Net

网上搜索一下。。无外乎两种情况:

  1. 输入的中划线“-”格式不对,检查是否为全角状态下输入,误输入了下划线“_”,或是前后有空格;
  2. 没有引用EntityFramework命令,请执行如下命令:
    Import-Module 项目路径\packages\EntityFramework.6.1.3(EF版本)\tools\EntityFramework.psd1

命令我是复制 过来的,肯定是第二种了,执行以后果然OK。


错误:ABP 默认语言未定义(Default language is not defined)

出现这个问题大部分人是因为尚未执行update-database命令,即尚未创建数据库,

具体步骤:

  1. 把Web项目作为启动项
  2. 打开程序包管理器控制台,把EntityFramework作为默认项目,并且执行Update-Database命令

如果你已创建数据库那你就要检查下Languages表里有没有数据了。

 

电子元件常用封装尺寸图

发布于:
其他(计算机)

贴片电阻常见封装有9种,用两种尺寸代码来表示。一种尺寸代码是由4位数字表示的EIA(美国电子工业协会)代码,前两位与后两位分别表示电阻的长与宽,以英寸为单位。我们常说的0603封装就是指英制代码。另一种是米制代码,也由4位数字表示,其单位为毫米。下表列出贴片电阻封装英制和公制的关系及详细的尺寸:

英制(inch) 公制(mm) 长(L)(mm) 宽(W)(mm) 高(t)(mm) a(mm) b(mm)
0201 0603 0.60±0.05 0.30±0.05 0.23±0.05 0.10±0.05 0.15±0.05
0402 1005 1.00±0.10 0.50±0.10 0.30±0.10 0.20±0.10 0.25±0.10
0603 1608 1.60±0.15 0.80±0.15 0.40±0.10 0.30±0.20 0.30±0.20
0805 2012 2.00±0.20 1.25±0.15 0.50±0.10 0.40±0.20 0.40±0.20
1206 3216 3.20±0.20 1.60±0.15 0.55±0.10 0.50±0.20 0.50±0.20
1210 3225 3.20±0.20 2.50±0.20 0.55±0.10 0.50±0.20 0.50±0.20
1812 4832 4.50±0.20 3.20±0.20 0.55±0.10 0.50±0.20 0.50±0.20
2010 5025 5.00±0.20 2.50±0.20 0.55±0.10 0.60±0.20 0.60±0.20
2512 6432 6.40±0.20 3.20±0.20 0.55±0.10 0.60±0.20 0.60±0.20

电子元件封装大全及封装常识

发布于:
其他(计算机)

一、  什么叫封装

封装,就是指把硅片上的电路管脚,用导线接引到外部接头处,以便与其它器件连接.封装形式是指安装半导体集成电路芯片用的外壳。它不仅起着安装、固定、密封、保护芯片及增强电热性能等方面的作用,而且还通过芯片上的接点用导线连接到封装外壳的引脚上,这些引脚又通过印刷电路板上的导线与其他器件相连接,从而实现内部芯片与外部电路的连接。因为芯片必须与外界隔离,以防止空气中的杂质对芯片电路的腐蚀而造成电气性能下降。另一方面,封装后的芯片也更便于安装和运输。由于封装技术的好坏还直接影响到芯片自身性能的发挥和与之连接的PCB(印制电路板)的设计和制造,因此它是至关重要的。

衡量一个芯片封装技术先进与否的重要指标是芯片面积与封装面积之比,这个比值越接近1越好。封装时主要考虑的因素:

  1. 芯片面积与封装面积之比为提高封装效率,尽量接近1:1;
  2. 引脚要尽量短以减少延迟,引脚间的距离尽量远,以保证互不干扰,提高性能;
  3.  基于散热的要求,封装越薄越好。