小编TLD*_*LDR的帖子

我什么时候应该使用 Pipes 或 gRPC 进行进程间通信(在 C# .NET Core 中)?

Pipes和 ASP.NET Core gRPC都支持本地和远程 IPC/RPC(gRPC 有一些平台限制)

我什么时候会使用一种技术(管道)或另一种技术(gRPC)?

我牢记的观察、想法和考虑:

  • gRPC 似乎旨在在未来的某些迭代中取代 WCF。

  • 本地部署和机器限制(以非管理员/用户身份运行、机器防火墙、不同平台/操作系统)

  • 网络穿越,兼容同机->多机(前后端阵列)负载扩展

  • 跨越安全区域(使用代理或其他 TLS 密码/顺序/注册表设置)会影响 HTTP/2 的工作能力

  • 管道(命名管道?)具有不同的表面积和端口(它们是否也使用端口 135 或 TCP 上的 NetBIOS(不确定名称))...它是如何扫描和保护的?

  • “内存映射文件”似乎是一个工作挑战,但它似乎可以在 UDS 配置中使用 gRPC 的 ASP.NET Core 中工作。这是一个正确的推论吗?

现在我的场景是让两个控制台应用程序在同一台机器或远程机器上相互通信。添加 Asp.NET Core Web 是我的场景的可选前端替代方案。

c# ipc named-pipes grpc asp.net-core-5.0

7
推荐指数
1
解决办法
9341
查看次数

出于安全目的,我应该了解哪些 cookie 域和范围?

我可以在哪里了解(或了解什么)cookie 的范围,以避免对经过身份验证的用户进行 CSRF 和 XSS 攻击?

例如,如果我有一个多租户系统,其中单个用户可以访问一个或多个站点,那么更安全的是:

  • company1.hoster.com
  • company2.hoster.com
  • company3.hoster.com

或者

  • www.hoster.com/company1
  • www.hoster.com/company2
  • www.hoster.com/company3

如果我在“hoster.com”设置 cookie 会发生什么?

javascript security cookies multi-tenant

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

Azure AD(工作)帐户可以与Azure B2C一起使用吗?这是个坏主意吗?

我需要使用AzureAD B2C支持工作帐户(或学校帐户).

我已经拥有Facebook客户和Google的现有基础.但是,当我配置Microsoft端点时,我只获得liveID选项.

有没有办法使用自定义B2C注册策略来使用AAD?还有哪些其他解决方案

azure azure-active-directory azure-ad-b2c azure-ad-msal

5
推荐指数
1
解决办法
947
查看次数

如何在 Identity Server 4 中配置“密钥材料”以使用 SQL、KeyVault 或任何其他系统?

ID4 的源代码要求我们“配置密钥材料”以用于生产。

在此处输入图片说明

我使用以下 Powershell 脚本创建了适用于 Identity Server 4 的密钥。

// (not necessary for this question, but others may find this useful)

[CmdletBinding()]
param(
    [Parameter(Mandatory=$true)][string]$password = "",
    [Parameter(Mandatory=$true)][string]$rootDomain = ""
)

#https://mcguirev10.com/2018/01/04/localhost-ssl-identityserver-certificates.html#identityserver-token-credentials
$cwd = Convert-Path .
$sCerFile = "$cwd\token_signing.cer"
$sPfxFile = "$cwd\token_signing.pfx"
$vCerFile = "$cwd\token_validation.cer"
$vPfxFile = "$cwd\token_validation.pfx"

# abort if files exist
if((Test-Path($sPfxFile)) -or (Test-Path($sCerFile)) -or (Test-Path($vPfxFile)) -or (Test-Path($vCerFile)))
{
    Write-Warning "Failed, token_signing or token_validation files already exist in current directory."
    Exit
}

function Get-NewCert ([string]$name)
{
    New-SelfSignedCertificate `
        -Subject …
Run Code Online (Sandbox Code Playgroud)

azure-web-app-service asp.net-core identityserver4

5
推荐指数
1
解决办法
3003
查看次数

Xamarin.Android.Targets失败,错误为“输入字符串的格式不正确”。

下面的错误包含“输入字符串的格式不正确。”,我无法弄清楚是什么原因导致了此问题。

如果需要,我可以发布更完整的项目/日志。该项目在iOS上运行良好

Target _CreateBaseApk:
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2246,3): error : Input string was not in a correct format.
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2246,3): error :   at System.Number.StringToNumber (System.String str, System.Globalization.NumberStyles options, System.Number+NumberBuffer& number, System.Globalization.NumberFormatInfo info, System.Boolean parseDecimal) [0x0005f] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/number.cs:1077 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2246,3): error :   at System.Number.ParseInt32 (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) [0x00013] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/number.cs:745 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2246,3): error :   at System.Int32.Parse (System.String s) [0x00000] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-06/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/int32.cs:120 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2246,3): error :   at Xamarin.Android.Tasks.ManifestDocument.CalculateVersionCode (System.String currentAbi, System.String versionCodePattern, System.String versionCodeProperties) [0x000bb] in <83926d11b31545cc8ffa045c79833692>:0 
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2246,3): error :   at Xamarin.Android.Tasks.Aapt.GenerateCommandLineCommands (System.String ManifestFile, System.String currentAbi, …
Run Code Online (Sandbox Code Playgroud)

xamarin.android xamarin xamarin-studio xamarin.forms

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

我应该使用哪些资源将我的.NET应用程序移植到Mono或Moonlight?

我有一些应用程序可能有资格移植到Linux/Mac平台,但首先我需要知道哪种技术基线对于兼容性是安全的,什么是边缘的,哪些是不受支持的.

是否有某个合并列表可以帮助我确定我的应用程序是否符合条件?

我应该注意哪些其他资源?

.net silverlight mono moonlight

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

可以在闭包内锁定()吗?在Lambdas和代码输出中看起来像什么?

我正在阅读这个问题,并阅读此回复

这实际上是一个很棒的功能.这允许你有一个闭包来访问通常隐藏的东西,比如私有类变量,并让它以受控的方式操作它作为对事件之类的响应.

您可以通过创建变量的本地副本并使用它来轻松模拟您想要的内容.

我们需要在这种情况下实现Lock()吗?

那会是什么样的?

根据Eric Lippert的说法,编译器使代码看起来像这样:

private class Locals
{
  public int count;
  public void Anonymous()
  {
    this.count++;
  }
}

public Action Counter()
{
  Locals locals = new Locals();
  locals.count = 0;
  Action counter = new Action(locals.Anonymous);
  return counter;
}
Run Code Online (Sandbox Code Playgroud)

Lambda会是什么样子,以及长格式代码?

c# events closures private-members

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

如何使用XPATH解析具有命名空间的以下内容?

我需要从SAML令牌中提取声明.我感兴趣的主张是http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider,在这种情况下,我希望获得"Google"的价值.

我在下面的代码中做错了什么?我已经编辑了我的令牌响应,但还没有正确

码:

    string strExpression = "//t:RequestSecurityTokenResponse/" +
            "t:RequestedSecurityToken/"+
            ""+"Assertion/AttributeStatement/Attribute";

        XmlDocument xmlDocument = new XmlDocument();
        xmlDocument.Load(@"claim.xml"); 
        XmlNode rootNode = xmlDocument.DocumentElement; 

        string ssNamespacePrefix = "t";
        string ssNamespaceURI = rootNode.GetNamespaceOfPrefix(ssNamespacePrefix);

        XPathNavigator xpathNav = xmlDocument.CreateNavigator();  

        XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmlDocument.NameTable);
        namespaceManager.AddNamespace(ssNamespacePrefix, ssNamespaceURI);

        XPathNodeIterator itr = xpathNav.Select(strExpression, namespaceManager);  
Run Code Online (Sandbox Code Playgroud)

数据:

<t:RequestSecurityTokenResponse Context="http://localhost:2600/" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">
    <t:Lifetime>
        <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2011-11-09T01:56:10.759Z</wsu:Created>
        <wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2011-11-09T02:06:10.759Z</wsu:Expires>
    </t:Lifetime>
    <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
        <EndpointReference xmlns="http://www.w3.org/2005/08/addressing">
            <Address>urn:federatasdf600</Address>
        </EndpointReference>
    </wsp:AppliesTo>
    <t:RequestedSecurityToken>
        <Assertion ID="_d70a5dasdfb868" IssueInstant="2011-11-09T01:56:10.775Z" Version="2.0" xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
            <Issuer>https://tlsadmin.accesscontrol.windows.net/</Issuer>
            <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                <ds:SignedInfo>
                    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                    <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256" /> …
Run Code Online (Sandbox Code Playgroud)

.net c# xpath xml-namespaces xpathnavigator

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

如何在.NET Core控制台应用程序中使用Microsoft.Extensions.DependencyInjection?

我有一个要在.NET Core支持的所有平台(Xamarin,Windows,Mac)上运行的库。为此,我需要一个跨平台的DI来处理特定于平台的自定义项,例如存储,安全性等。

我见过的所有示例都Microsoft.Extensions.DependencyInjection包含ASP.NET Core的代码。控制台应用程序是否存在任何等效/受支持的方案?

另外(理想情况下),我希望用于控制台的DI框架适用于ASP.NET Core,Xamarin和Win32

错误示例

将此代码用作.NET Core应用程序的基础。看来ServiceCollection应该是公共的,但是当我在Mac上使用Xamarin时,IServiceCollection缺少(ServiceCollection)的默认实现:

在此处输入图片说明

c# dependency-injection console-application xamarin .net-core

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

为什么命令行现在每个参数后面都有两个连字符(-)?它起源于何处,为什么不使用单个连字符?

.NET Core和几个javascript库现在似乎对每个命令行参数使用两个连字符。

为什么现在突然发生这种情况?

它有任何(历史)意义吗?

为什么不只使用一个连字符?(我们要遵循什么约定?xNix?)

javascript node.js .net-core asp.net-core

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