小编Kev*_*ang的帖子

ExecutionContext.InvokeCommand.ExpandString在PowerShell 4.0中引发异常

我有一个脚本如下

[string] $ newValue = Get-ConfigurationByType $ setting.Value

在此行之后,$ newValue的值为

"http://ST-$($partner.Alias).vardiaforsakring.se/CardPaymentAgreementCallback.aspx"

在循环中,我调用ExpandString

foreach ($partner in $partners) { $partnerSpecificValue =$ExecutionContext.InvokeCommand.ExpandString($newValue) }

它抛出异常

Exception calling "ExpandString" with "1" argument(s): "Object reference not set to an instance of an object."
At C:\Programs\Drops\Hydra_SE_v1.28\HydraDeploymentFunctions.ps1:342 char:5
+                 $partnerSpecificValue = $ExecutionContext.InvokeCommand.ExpandString($newVal ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NullReferenceException

但是当我尝试输入硬编码字符串时,它会毫无例外地返回预期的结果

$partnerSpecificValue =$ExecutionContext.InvokeCommand.ExpandString("http://ST-$($partner.Alias).vardiaforsakring.se/CardPaymentAgreementCallback.aspx")

$ partnerSpecificValue的值是

http://ST-secure.vardiaforsakring.se/CardPaymentAgreementCallback.aspx

有没有人知道解决这个bug的解决方法?非常感谢你.我在Windows Server 2012 R2上运行PowerShell v4.0.

powershell powershell-4.0

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

在asp.net core 2.0中使用identityserver4时的无限认证循环

我有一个使用identityserver4框架的Identity Server,它的URL是http:// localhost:9000

我的Web应用程序是asp.net core 2.0,其URL是http:// localhost:60002.此应用程序将使用Identity Server的登录页面.

我想在登录后,Identity Server将重定向到应用程序页面(http:// localhost:60002)

这是客户端应用程序的Startup.cs

Startup.cs

public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        private string AuthorityUri => Configuration.GetValue<string>("UserManagement-Authority");

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();            

            services.AddAuthentication(options =>
            {
                options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
            })
            .AddCookie()
            .AddOpenIdConnect(options =>
            {
                options.SignInScheme = …
Run Code Online (Sandbox Code Playgroud)

identityserver4 asp.net-core-2.0

5
推荐指数
3
解决办法
1641
查看次数

无法在ASP.NET Core 2应用程序上注销identityserver4的OpenIdConnect身份验证

我的Identity Server使用identityserver4框架(http:// localhost:9000).我在Identity Server上注册客户端,如下所示.

clients.Add(
     new Client
     {
         ClientId = "customer.api",
         ClientName = "Customer services",
         AllowedGrantTypes = GrantTypes.HybridAndClientCredentials,
         RequireConsent = false,
         AllowAccessTokensViaBrowser = true,

         RedirectUris = { "http://localhost:60001/signin-oidc" },
         PostLogoutRedirectUris = { "http://localhost:60001/signout-callback-oidc" },
         ClientSecrets = new List<Secret>
         {
             new Secret("testsecret".Sha256())
         },
         AllowedScopes = new List<string>
         {
             IdentityServerConstants.StandardScopes.OpenId,
             IdentityServerConstants.StandardScopes.Profile,
             IdentityServerConstants.StandardScopes.Email,
             IdentityServerConstants.StandardScopes.OfflineAccess,
             "customerprivatelinesvn.api",                        
         },
         AllowOfflineAccess = true,
         AlwaysIncludeUserClaimsInIdToken = true,
         AllowedCorsOrigins = { "http://localhost:60001" }
     });  
Run Code Online (Sandbox Code Playgroud)

这是我的客户端应用程序上的身份验证(http:// localhost:60001).

private void AddAuthentication(IServiceCollection services)
{
    JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

    services.AddAuthentication(options =>
    { …
Run Code Online (Sandbox Code Playgroud)

identityserver4 asp.net-core-2.0

4
推荐指数
3
解决办法
7646
查看次数