小编Jim*_*Jim的帖子

docker无法在Windows上启动

执行docker version返回以下结果.

C:\Projects> docker version
Client:
 Version:      1.13.0-dev
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   d8d3314
 Built:        Tue Nov  1 03:05:34 2016
 OS/Arch:      windows/amd64
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.25/version: open //./pipe/docker_engine: The system cannot find the file
specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
Run Code Online (Sandbox Code Playgroud)

运行诊断程序会产生以下结果:

C:\Projects> wget https://github.com/Microsoft/Virtualization- 
Documentation/raw/master/windows-server-container-tools/Debug- 
ContainerHost/Debug-ContainerHost.ps1 -UseBasicParsin | iex

Checking for …
Run Code Online (Sandbox Code Playgroud)

docker docker-for-windows

60
推荐指数
17
解决办法
8万
查看次数

ASP.NET核心,更改默认重定向未授权

我试图重定向到ASP.NET MVC6中的另一个登录URL

我的帐户控制器登录方法有一个Route属性来更改网址.

[HttpGet]
[AllowAnonymous]
[Route("login")]
public IActionResult Login(string returnUrl = null)
{
    this.ViewData["ReturnUrl"] = returnUrl;
    return this.View();
}
Run Code Online (Sandbox Code Playgroud)

当我试图访问一个非正式的页面时,我被重定向到无效的网址,它应该只是/login但是我得到了 http://localhost/Account/Login?ReturnUrl=%2Fhome%2Findex

我已经配置了cookie身份验证路径,如下所示:

services.Configure<CookieAuthenticationOptions>(opt =>
{
    opt.LoginPath = new PathString("/login");
});
Run Code Online (Sandbox Code Playgroud)

我添加了一个默认过滤器,以确保默认情况下所有URL都需要身份验证.

services.AddMvc(
    options =>
    {
        options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
    });
Run Code Online (Sandbox Code Playgroud)

我已经检查过url /login确实加载了登录页面,而/account/login没有按预期加载.

编辑:我已按原样离开路线,(除了更改默认控制器和操作)

app.UseMvc(routes =>
{
    routes.MapRoute(
      name: "default",
      template: "{controller=Site}/{action=Site}/{id?}");
});
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-identity asp.net-core-mvc asp.net-core

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

flexbox:最小间距

鉴于此scss/css:

div.container {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-between;
  border: 1px solid blue;
}
div.container div {
  width: 200px;
  border: 1px solid gray;
  display: inline-block;
  text-align: center;
}
Run Code Online (Sandbox Code Playgroud)

此布局使每行中的第一个项目与左侧对齐,最后一个项目根据需要与右侧对齐.这是一个代码说明.

随着浏览器窗口变窄,分布式div元素将一起移动直到它们接触,此时它们被重新排列在另一行上.同样,每行的第一个div左对齐,最后一个对齐,右边有空格.

有没有办法设置最小间距,以便内部div元素之间始终有间隙.

对齐时,填充和边距可能不起作用

<-- 1st left in row并且last right in row -->不会举行.

html css flexbox

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

HttpClient:uri字符串太长

鉴于以下尝试将数据发布到生成PDF文件的Web服务,PDF rocket(顺便说一句,这很棒).

我收到错误无效的URI:uri字符串太长
为什么有人会对POSTed数据施加任意限制?

using (var client = new HttpClient())
{
    // Build the conversion options
    var options = new Dictionary<string, string>
    {
        { "value", html },
        { "apikey", ConfigurationManager.AppSettings["pdf:key"] },
        { "MarginLeft", "10" },
        { "MarginRight", "10" }
    };

    // THIS LINE RAISES THE EXCEPTION
    var content = new FormUrlEncodedContent(options);

    var response = await client.PostAsync("https://api.html2pdfrocket.com/pdf", content);
    var result = await response.Content.ReadAsByteArrayAsync();
    return result;
}
Run Code Online (Sandbox Code Playgroud)

我收到了这个荒谬的错误.

 {System.UriFormatException: Invalid URI: The Uri string is …
Run Code Online (Sandbox Code Playgroud)

c# dotnet-httpclient

15
推荐指数
4
解决办法
2万
查看次数

在HashSet <T>中包含线程安全

看一下.NET源代码Contains中的HashSet<T>类代码,我找不到任何Contains线程安全的原因?

HashSet<T>提前加载了一个值,然后检查Contains多线程.AsParallel()环.

这有什么理由不安全吗?ConcurrentDictionary当我实际上不需要存储值时,我不愿意使用.

c# multithreading hashset

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

typescript 2.1 with async/await为angularjs生成ES5/ES3目标

我试图async/await在一个角度1.5.5项目中使用.

鉴于这种服务方法

    getDocumentTypes(): angular.IPromise<DocumentType[]> {
        var url = "api/document/types";
        this.$log.log(url);
        return this.$http.get(url).then(_ => _.data);
    }
Run Code Online (Sandbox Code Playgroud)

我正在尝试创建async / await该方法的一个版本.

    async getDocTypes(): angular.IPromise<DocumentType[]> {
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    }}
Run Code Online (Sandbox Code Playgroud)

Intellisense显示错误:TS1055 类型'angular.IPromise'不是有效的异步函数返回类型,ES5/ES3因为它不引用与Promise兼容的构造函数值.

有没有使用正确的方式角承诺打字稿2.1async/ await

javascript interface promise async-await typescript

12
推荐指数
1
解决办法
2572
查看次数

在 intelij 中将 jar 依赖项添加到暂存文件的简单方法

我创建了一个临时文件 scratch.java

我添加了一个新的纯 java 模块,其中包含以下内容:

在此处输入图片说明

我已经在暂存文件的构建配置中指定了依赖项:

当我尝试编辑和构建临时文件时找不到依赖项。
如何轻松地向 intelij 中的暂存文件添加依赖项?

在此处输入图片说明

java jar intellij-idea

12
推荐指数
1
解决办法
3354
查看次数

rdlc中的子对象(Studio 2010RC)

我试图在studio 2010报告中引用字段表达式中的子对象.这曾用于以前的版本.当帐户引用具有属性的另一个对象时,以下用于工作.

=Fields!Account.Value.Name
Run Code Online (Sandbox Code Playgroud)

(Name是子对象的属性,Account是父对象)

相同的表达式语法不再有效.如何在studio 2010中的rdlc中引用报表服务中子对象的属性.

谢谢

report rdlc visual-studio

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

在动作过滤器中添加参数/查询字符串值.c#mvc3

当我尝试将参数或查询字符串值添加到操作过滤器内的上下文时,会引发异常以表明该集合是只读的.

我想在创建时向"传出"网址添加值.

filterContext.ActionParameters.Add("test", "test");
Run Code Online (Sandbox Code Playgroud)

我需要将这些值传递给查询字符串或请求参数.谢谢

c# asp.net-mvc

9
推荐指数
1
解决办法
5419
查看次数

从另外两个创建动态表达式lambda(链接表达式)

给定一个带有Identification对象的lambda,并返回一个属性:

Expression<Func<Identification, object>> fx = _ => _.Id;
Run Code Online (Sandbox Code Playgroud)

以及将对象转换为标识实例的转换lambda:

ParameterExpression p = Expression.Parameter(typeof(object), "o");
Expression @new = Expression.Lambda(Expression.Convert(p, typeof(Identification)), p);
Run Code Online (Sandbox Code Playgroud)

如何构建一个执行@new(获取标识实例)并将结果传递给的新lambda fx.我需要@new的结果以fx某种方式绑定到第一个参数,我找不到一个例子.

我需要结果是一个Expression,它应该是类型Expression<Func<object, object>>,它应该将入站参数转换为a Identification然后获取Id属性.

c# lambda expression runtime dynamic

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