小编Bal*_*tar的帖子

cURL抑制反应体

是否有可能指示cURL抑制响应体的输出?

在我的例子中,响应主体是一个HTML页面,它溢出CLI缓冲区,使得很难找到相关信息.我想检查输出的其他部分,如HTTP响应代码,标题等 - 除了实际的HTML 之外的所有内容.

curl suppress output

86
推荐指数
4
解决办法
5万
查看次数

PowerShell:按字段值检索JSON对象

考虑这种格式的JSON:

"Stuffs": [
    {
        "Name": "Darts",
        "Type": "Fun Stuff"
    },
    {
        "Name": "Clean Toilet",
        "Type": "Boring Stuff"
    }
]
Run Code Online (Sandbox Code Playgroud)

在PowerShell 3中,我们可以获得一个Stuffs列表:

$JSON = Get-Content $jsonConfigFile | Out-String | ConvertFrom-Json
Run Code Online (Sandbox Code Playgroud)

假设我们不知道列表的确切内容,包括对象的排序,我们如何检索具有Name字段的特定值的对象?

蛮力,我们可以遍历列表:

foreach( $Stuff in $JSON.Stuffs ) { 
Run Code Online (Sandbox Code Playgroud)

但我希望存在一种更直接的机制(类似于C#中的Lync或Lambda表达式).

powershell json powershell-3.0

49
推荐指数
4
解决办法
11万
查看次数

如何将纯文本发布到ASP.NET Web API端点?

我有一个ASP.NET Web API端点,其控制器操作定义如下:

[HttpPost]
public HttpResponseMessage Post([FromBody] object text)
Run Code Online (Sandbox Code Playgroud)

如果我的帖子请求正文包含纯文本(即不应该被解释为json,xml或任何其他特殊格式),那么我认为我可以在我的请求中包含以下标题:

Content-Type: text/plain
Run Code Online (Sandbox Code Playgroud)

但是,我收到错误:

No MediaTypeFormatter is available to read an object of type 'Object' from content with media type 'text/plain'.
Run Code Online (Sandbox Code Playgroud)

如果我将控制器操作方法签名更改为:

[HttpPost]
public HttpResponseMessage Post([FromBody] string text)
Run Code Online (Sandbox Code Playgroud)

我得到一个略有不同的错误消息:

No MediaTypeFormatter is available to read an object of type 'String' from content with media type 'text/plain'.
Run Code Online (Sandbox Code Playgroud)

text content-type http-post http-request asp.net-web-api

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

如何安装Git Shell

Windows 7旗舰版

我曾经安装过Git Shell.图标是灰色的猫脸.它由Git或GitHub for Windows安装.

不知怎的,我已经失去了它.

我已经尝试重新安装Windows的Git和GitHub,但我无法取回它.

windows git shell

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

通过PowerShell脚本安装NuGet

据我所知,NuGet应该作为Visual Studio扩展安装:

http://docs.nuget.org/docs/start-here/installing-nuget
Run Code Online (Sandbox Code Playgroud)

但是如果我在没有安装VS的机器上需要NuGet呢?

具体来说,我想通过PowerShell脚本安装NuGet.

powershell nuget powershell-3.0

25
推荐指数
5
解决办法
5万
查看次数

Visual Studio:NuGet包源需要凭据

Visual Studio 2012 > Tools > Options > Package Manager > Package Sources
Run Code Online (Sandbox Code Playgroud)

我添加了一个指向myget.org网址的新Package Source:

http://www.myget.org/F/myfeed/

VS > Tools > Library Package Manager > Manage NuGet Packages for Solution...
Run Code Online (Sandbox Code Playgroud)

我现在被提示输入myget凭据.显然,开发人员每次使用myget包时都必须手动输入凭据,这是不方便的.

此博客介绍了如何在机器级NuGet.config中存储凭据:

https://gist.github.com/xavierdecoster/3205826

但在我按照步骤操作后,VS仍然会提示我输入凭据.

visual-studio nuget nuget-package myget

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

使用PowerShell连接文件

我正在使用PowerShell 3.

连接文件的最佳做法是什么?

file1.txt + file2.txt = file3.txt
Run Code Online (Sandbox Code Playgroud)

PowerShell是否提供直接执行此操作的工具?或者我是否需要将每个文件的内容加载到局部变量中?

powershell powershell-3.0

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

IIS如何确定ApplicationPoolIdentity帐户?

Windows Server 2008 R2 Standard ( Microsoft Windows Server Version 6.1 Build 7601: Service Pack 1 )

IIS 7.5.7600.16385

IIS Manager一个Site指定的ApplicationPoolIdentity= ApplicationPoolIdentity(默认设置),如何确定Windows帐户的网站使用的目录操作?

在以前的版本中IIS,Application PoolsNetwork Service帐户下运行.

什么是默认帐户ApplicationPoolIdentity

IIS Manager> Server Instance> Application Pools> Application Pool>右键单击Set Application Pool Defaults...-或-Advanced Settings

两者都调用相同的对话框,其中包含一个Identity带有...按钮的字段,该按钮允许设置标识 - 否在哪里指定与哪个帐户关联ApplicationPoolIdentity或允许设置该值

account application-pool iis-7.5 windows-server-2008-r2 applicationpoolidentity

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

Windsor解析IEnumerable <IMyType>

通过Windsor我将多种实现类型注册到单个接口类型:

public class WindsorInstaller : IWindsorInstaller
  {
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
      container.Register(
        Component.For<IMyType>()
          .ImplementedBy<MyTypeClass1>()
          .Named("MyTypeClass1")
          .LifestyleTransient());

      container.Register(
        Component.For<IMyType>()
          .ImplementedBy<MyTypeClass2>()
          .Named("MyTypeClass2")
          .LifestyleTransient());
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我有一个消费类:

public class MyConsumingClass : IMyConsumingClass
  {
    private readonly IList<IMyType> _myObjects;

    public MyConsumingClass(IEnumerable<IMyType> myObjects)
    {
      _myObjects = myObjects.ToList();
    }
}   
Run Code Online (Sandbox Code Playgroud)

但是在运行时我收到以下异常:

Can't create component 'MyConsumingClass' as it has dependencies to be satisfied. 'MyConsumingClass' is waiting for the following dependencies: - 'System.Collections.Generic.IEnumerable`1[[IMyType, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' which was not registered.
Run Code Online (Sandbox Code Playgroud)

.net c# dependency-injection castle-windsor inversion-of-control

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

.NET CLI (dotnet) Build:从解决方案中排除项目

TeamCity .NET CLI (dotnet) 构建

使用多个项目 (.csproj) 构建 Visual Studio 解决方案 (.sln)。

是否可以从构建中排除某个项目?

这是一个没有其他项目依赖的项目。

teamcity build visual-studio

8
推荐指数
1
解决办法
4481
查看次数