小编Lar*_*rsi的帖子

GetExternalLoginInfoAsync()loginInfo返回null - 但仅在几个小时后

我正在使用Strava作为我的外部登录提供商(我认为这与Strava无关,也可能是google或facebook)运行几小时/几天甚至几周后,GetExternalLoginInfoAsync返回null.我已经阅读了同样问题的一堆其他问题,但没有找到解决方案.我发布了我的整个ConfigureAuth方法,以防我在订单上做错了.

如果你有一个strava帐户,你可能会在这里遇到问题:fartslek.no/Account/Login

    public void ConfigureAuth(IAppBuilder app)
    {
        // Configure the db context, user manager and signin manager to use a single instance per request
        app.CreatePerOwinContext(ApplicationDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);

        // Enable the application to use a cookie to store information for the signed in user
        // and to use a cookie to temporarily store information about a user logging in with a third party login provider
        // Configure the sign in cookie
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new …
Run Code Online (Sandbox Code Playgroud)

asp.net authentication asp.net-mvc azure-web-sites owin

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

Application Insight 将跨服务和队列的请求关联起来

我知道我可以使用 clienttrackid 并将其设置在标题中,但我不确定应用程序洞察/azure 处理什么以及我需要手动处理什么。情况就是这样(我希望将来自 ServiceA、FunctionA、ServiceB 的日志视为相关事件):

  • Clientapp 调用 ServiceA
  • ServicesA 向队列添加消息
  • FunctionA 由队列触发,并调用 ServiceB

我是否需要将跟踪 ID 添加到我添加到队列中的消息中?还是一切都是自动处理的?

谢谢拉西

azure azure-queues azure-application-insights azure-web-app-service azure-functions

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

将文本放在fontawesome图标内

我想添加一些文本堆叠在另一个图标内.这是我的尝试:

  <!-- How should I style this to work properly with fa-1x and fa-5x ???? -->
  <span class="fa-stack fa-1x">
     <i class="fa fa-calendar-o fa-stack-2x"></i>
     <span class="fa fa-stack-1x">31</span>
  </span>
Run Code Online (Sandbox Code Playgroud)

当使用fa-1x和fa-5x时,有没有什么方法可以正确定位?

http://jsbin.com/opOwENe/3/edit

Larsi

font-awesome

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

添加角色声明-我应该使用IClaimsTransformer吗

我们想在当前主体中添加很多角色声明(我们使用Authorize(Roles)属性),并发现IClaimsTransformer这看起来很合适。

我们已经registerd像这样

 app.UseClaimsTransformation(new ClaimsTransformationOptions
        {
            Transformer = new GetRolesFromDatabaseClaimsTransformer(new RoleManager2(Configuration.GetConnectionString("ourcoolapp")))
        });
Run Code Online (Sandbox Code Playgroud)

而变换是这样的:

public Task<ClaimsPrincipal> TransformAsync(ClaimsTransformationContext context)
{
        // A hacky way to not load on all requests. Better ideas?
        if (!context.Context.Request.Path.Value.Contains("api/"))
        {
            return Task.FromResult(context.Principal);
        }

        var roleClaims = RoleManager.GetRolesForUser(context.Principal.Identity.Name).Select(roleName => new Claim("role", roleName));

        var claims = new List<Claim> { };
        var identity = context.Principal.Identity as ClaimsIdentity;
        claims.AddRange(identity.Claims);
        claims.AddRange(roleClaims);

        var userIdentity = new ClaimsIdentity(claims, "local");
        var userPrinicpal = new ClaimsPrincipal(userIdentity);

        return Task.FromResult(userPrinicpal);
}
Run Code Online (Sandbox Code Playgroud)

问题:是否有其他或更聪明的方法来添加角色声明?

谢谢

Larsi

claims-based-identity authorize-attribute asp.net-web-api asp.net-identity .net-core

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

当 sw 放置在子文件夹中时 navigator.serviceWorker.ready 不会触发

我们的应用程序由https://myserver.com/myapp提供服务(由虚拟应用程序中的 IIS 提供)

从https://myserver.com/myapp返回的 HTML为:

<html>
  <!-- This file is served as a virtual application from https://myserver.com/myapp-->
  <head>
    <script src="/myapp/file.js"></script>
  </head>
<body>
</body>
Run Code Online (Sandbox Code Playgroud)

要注册服务人员,我需要添加子文件夹,如下所示

// This does not work since the app is served from /myapp
navigator.serviceWorker.register("/sw.js")  // Fail, will try loading https://myServer.com/sw.js

// This works (registration successful)
navigator.serviceWorker.register("/myapp/sw.js")  // This will register the sw.
Run Code Online (Sandbox Code Playgroud)

当我尝试使用正在等待就绪事件的服务工作者时,出现问题:

// Inside of file.js
navigator.serviceWorker.ready.then(...) // Will not fire
Run Code Online (Sandbox Code Playgroud)

我猜发生的情况是,ready 事件没有触发,因为 serviceworker“认为”它是从名为“MyApp”的子文件夹安装的,但是当 file.js 运行并尝试使用 serviceworker 时,它看起来像文件.js 从 root 提供服务,因此超出了 serviceworker 的范围。

关于如何处理这个问题有什么想法吗?我尝试使用范围参数,但我认为这仅用于限制范围,而不是扩展范围。 …

service-worker

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

DefaultConnection和membership - localsqlserver和defaultconnection之间的连接是什么

嗯...我真的无法理解这一点.

在web.config我有:

<connectionStrings>
   <clear /> <!--- need this to prevent using LocalSqlServer from machine.config or somewhere becouse it is not present when when publish to hosting -->
   <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-Goaly-20120615111028;Integrated Security=SSPI" />  
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)

<membership defaultProvider="DefaultMembershipProvider">
  <providers>
    <!-- I think this line is telling asp.net that I want the membership working agains defaultconnection, and not LocalSqlServer connection????? -->
    <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
  </providers> …
Run Code Online (Sandbox Code Playgroud)

asp.net entity-framework connection-string asp.net-membership

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

如何注册 MediatR 后处理器

我想在 MediatR 中尝试新的管道功能:https : //github.com/jbogard/MediatR/wiki/Behaviors

我尝试了以下操作,但没有执行

services.AddMediatR();                    
services.AddTransient(typeof(IRequestPostProcessor<,>), typeof(PostHandler<,>));
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

.net-core mediatr

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

设置默认构建代理VSTS

如何选择CI构建使用的池(或代理)?当我选择"manage"(在构建摘要的默认队列旁边)时,我看到了一个池列表,我有权创建一个新池"laptops",但无法选择此作为默认值.它总是以"Hosted"结尾(并且那里还不支持网络核心.csproj)

Larsi

azure-devops azure-pipelines

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

使用oidc-client检索状态数据

如何保留用户导航到的原始URL?说我有一个未经身份验证的用户导航到http:// localhost:9000 / customer / 123

要验证用户身份,我将执行以下操作:

// in my app.js  
new Oidc.UserManager().signinRedirect({state:'customer/123'}); // need a way to keep this url
Run Code Online (Sandbox Code Playgroud)

当返回到callback.html时,我需要一种访问原始URL的方法:

// callback.html
<script src="oidc-client.js"></script>
<script>
    Oidc.Log.logger = console;
    new Oidc.UserManager().signinRedirectCallback().then(function () {

        var state = 'customer/123' // how to do a redirect to the page originally requested page?
        window.location.href="http://localhost:9000/ + state 
    }).catch(function (e) {
        console.error(e);
    });
</script>
Run Code Online (Sandbox Code Playgroud)

或者,也许还有其他获取原始网址的方式?

谢谢你的帮助!

oauth-2.0 identityserver4 implicit-flow oidc-client-js

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

得到字符串"AA,BB,CC"想要"'AA','BB','CC''" - 我可以更聪明地做吗?

我知道我可以这样做:

        string input = "AA,BB,CC";
        string output = "";
        foreach (var item in input.Split(','))
        {
            output += string.Format("'{0}',", item);
        };
        output =output.TrimEnd(',');

        Assert.AreEqual("'AA','BB','CC'", output);
Run Code Online (Sandbox Code Playgroud)

但是,可能会有更聪明,更快捷的方法.

谢谢你的任何想法.

Larsi

c# string

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

AzureFunctions 绑定到 SendGrid

试图弄清楚如何从 azure 函数中使用 SendGrid。找不到太多文档,但这是我尝试过的:

#r "SendGrid"
using SendGrid.Helpers.Mail;
using System;

public static void Run(string myQueueItem, out Mail message, TraceWriter log)
{
    log.Info($"C# Queue trigger function processed: {myQueueItem}");
    message=new Mail();
}
Run Code Online (Sandbox Code Playgroud)

我已经对主题和正文以及集成输出部分中的 api 密钥进行了硬编码。这是我的function.json:

{
"bindings": [
{
  "name": "myQueueItem",
  "type": "queueTrigger",
  "direction": "in",
  "queueName": "send-email-request",
  "connection": "myStorage"
},
{
  "type": "sendGrid",
  "name": "message",
  "apiKey": "SG.xxxxxxxxxxx",
  "direction": "out",
  "to": "me@gmail.com",
  "from": "me@gmail.no",
  "subject": "hardcoded",
  "text": "test213"
}
],
"disabled": false
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Function ($SendEmailOnQueueTriggered) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.SendEmailOnQueueTriggered'. Microsoft.Azure.WebJobs.Host: …
Run Code Online (Sandbox Code Playgroud)

azure sendgrid azure-functions

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

什么是linq查询将取代我的两个foreach

我想知道如何更换下面的两个foreach.

        public void UpdateChangedRows(List<Row> changedRows)
    {
        // How to write linq to update the rows (example code using foreach)
        foreach (Row row in table.Rows)
        {
            foreach (Row changedRow in changedRows)
            {
                if (row.RowId==changedRow.RowId)
                {
                    row.Values = changedRow.Values;
                }
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

我认为会有一种linq方式来执行相同的操作.谢谢你的帮助.

Larsi

linq

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