小编Kay*_*yes的帖子

VSCode launch.json 用于调试子文件夹中的节点项目

我有一个节点项目作为我的主项目中的子文件夹。我正在尝试为 VS Code 创建启动配置,以便在我打开父文件夹时它开始调试 index.ts 文件。我的文件夹结构如下: 文件夹结构

所以我的节点项目位于名为 NodeBackend 的子文件夹中。我想按 VS Code 上的 F5 或绿色按钮并开始调试我的打字稿文件。

当我从父文件夹中执行此操作时,出现错误:

Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
Run Code Online (Sandbox Code Playgroud)

但是,当我在 VS 代码中加载“NodeBackend”项目并按 F5 或绿色按钮时,我可以毫无问题地调试它。

我的启动.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "cwd": "${workspaceFolder}\\NodeBackend",
            "name": "Launch Program",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "program": "${workspaceFolder}\\NodeBackend\\src\\index.ts",
            "outFiles": [
                "${workspaceFolder}/**/*.js"
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

这是我的源代码: https: //github.com/Kayes-Islam/SimpleProject

node.js visual-studio-code

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

Xamarin.Auth Facebook 给出 NullReferenceException 2

我正在关注此页面以及 Xamarin.Auth github 存储库中的一些示例,因此设置了 Facebook 登录。我创建了以下登录功能:

public void Authenticate()
{
    string clientId = Config.FacebookAppID;
    string redirectUri = redirectUri = "MyApp:/authorize";
    var authenticator = new OAuth2Authenticator(
        clientId: clientId,
        scope: "public_profile,email",
        authorizeUrl: new Uri("https://www.facebook.com/v2.9/dialog/oauth"),
        redirectUrl: new Uri(redirectUri),
        getUsernameAsync: null,
        isUsingNativeUI: true);

    authenticator.AllowCancel = true;
    authenticator.Completed += OnAuthCompleted;
    authenticator.Error += OnAuthError;
    Authenticator = authenticator;

    var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
    presenter.Login(Authenticator);
}
Run Code Online (Sandbox Code Playgroud)

但我在最后一行收到以下异常:

{System.NullReferenceException: Object reference not set to an instance of an object.
  at Xamarin.Auth.Presenters.OAuthLoginPresenter.Login (Xamarin.Auth.Authenticator authenticator) [0x00011] in C:\cxa\source\Xamarin.Auth.LinkSource\Request.cs:290 
  at …
Run Code Online (Sandbox Code Playgroud)

xamarin xamarin.auth

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

在Azure上部署Angular 5 build:ssr

我已经从这里找到的角度通用模板开始构建了我的项目: Universal-starter

我正在尝试将ssr构建部署为azure Web应用程序。我的代码在VSTS上。

在我的本地计算机上,我可以运行以下命令:

  1. npm install
  2. npm run build:ssr。这将产生dist文件夹。
  3. 然后,我可以将dist文件夹复制到其他位置,并使用以下命令运行
  4. node server.js

该应用程序在本地计算机上的端口4000上启动。

因此,按照上述步骤,我在VSTS上创建了一个构建过程,其中包含以下任务:

  1. 运行的npm任务 npm install
  2. 运行的npm任务 npm run build:ssr
  3. 具有以下配置的azure应用程序服务部署任务:
    • 包文件夹:dist /
    • web.config参数:-Handler iisnode -NodeStartFile server.js -appType节点

上面的过程成功运行,但是当我导航到https://my-site-name.azurewebsites.net/时,无法访问该站点。

如何在Azure上成功部署Angular 5 SSR?

更新: 由于此NodeJS-EmptySiteTemplate在azure上运行而没有错误,因此我对该项目进行了以下更改:

  1. 该服务器正在侦听process.env.PORT | 8080
  2. 我在那里缺少一个web.config文件。我将相同的Web配置文件放在wwwroot中。

但是我没有得到:“由于发生内部服务器错误,因此无法显示该页面。”

azure azure-devops ssr angular5

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

B2C认证不返回access_token

我正在尝试使用 PKCE 一个有角度的项目来实现授权代码流。我正在使用 angular-auth-oidc-client。我们已经有一个基于 IdentityServer4 的现有内部实施,客户端可以很好地配合该实施,但我们现在正在尝试将身份验证迁移到 Azure AD B2C,而不是在内部实施。

我已经配置了 Azure AD B2C 和我的客户端应用程序。这是配置: 我的应用程序配置

这是我在客户端 OIDC 服务上的配置:

oidcConfigService.withConfig({
    stsServer: 'https://login.microsoftonline.com/mycompany.onmicrosoft.com/v2.0',
    authWellknownEndpoint:
        'https://mycompany.b2clogin.com/mycompany.onmicrosoft.com/B2C_1_SignUpSignIn/v2.0/.well-known/openid-configuration',
    redirectUrl: window.location.origin,
    postLogoutRedirectUri: window.location.origin,
    clientId: 'client-id-guid-goes-here',
    scope: 'openid profile offline_access',
    responseType: 'code',
    silentRenew: true,
    autoUserinfo: false,
    silentRenewUrl: window.location.origin + '/silent-renew.html',
    logLevel: LogLevel.Debug,
    renewTimeBeforeTokenExpiresInSeconds: 60
});
Run Code Online (Sandbox Code Playgroud)

问题:令牌响应中没有访问令牌: 没有access_token

即使我在客户端配置中选中了 accesss_token 复选框。我在这里缺少什么?

access-token openid-connect azure-ad-b2c pkce angular-auth-oidc-client

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

Flutter 可滚动导航抽屉,其中一个菜单项与底部对齐

我有一个带有一堆项目的导航抽屉,我希望注销项目与抽屉的最底部对齐。

return Drawer(
  child: Column(
    children: [
      DrawerAccountHeader(UserType.worker),
      DrawerNavigationItem(
        "Home", 
        Icons.home,
      ),
      new ListTile(
        title: new Text('Jobs', style: TextStyle(color: Colors.black54),),
        dense: true,
      ),
      DrawerNavigationItem(
        "Nearby", 
        Icons.location_on, 
      ),
      DrawerNavigationItem(
        "Applied", 
        Icons.check_circle_outline, 
      ),
      DrawerNavigationItem(
        "Hired", 
        Icons.check_circle, 
      ),
      Expanded(child: Container()),
      Divider(),
      DrawerNavigationItem(
        "Logout",
        Icons.exit_to_app,               
      )
    ],
  ),
);
Run Code Online (Sandbox Code Playgroud)

看起来怎么样

但在较小的屏幕上,我收到溢出错误,因为最上面的列高度大于屏幕高度。因此,我尝试将列更改为列表框,然后出现异常“垂直视口被赋予无界高度”,因为我在项目之间有 Expanded() 来形成间隙,以便登录按钮粘在列表的底部。

下面有什么办法可以实现吗?

  1. 当有垂直空间时,将登录按钮(可能还有一组按钮)固定在屏幕底部。
  2. 当没有足够的垂直空间时,使抽屉项目可滚动。
  3. (nice to have) 可滚动的,整个抽屉都可以滚动。即,在小屏幕上,用户需要滚动抽屉才能到达注销选项。

flutter flutter-layout

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

MVC 4 Async Action 不处理等待之间的多个请求

我正在尝试测试我从这里阅读最多的 MVC4 异步控制器操作:http : //www.asp.net/mvc/tutorials/mvc-4/using-asynchronous-methods-in-aspnet-mvc-4

下面是我的控制器:

public class HomeController : AsyncController
{
    //
    // GET: /Home/

    public async Task<ActionResult> Index()
    {
        WriteOnFile("Here dude. Time: " + DateTime.Now.ToString("HH:mm:ss:fff"));
        await Task.Delay(10000);
        return View();
    }

    private void WriteOnFile(string text)
    {
        using (Mutex mutex = new Mutex(false, "TempFile"))
        {
            mutex.WaitOne();
            using (var writer = new StreamWriter(@"D:\Temp\temp.txt", true))
            {
                writer.WriteLine(text);
            }
            mutex.ReleaseMutex();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我正在通过打开指向 ~/home/index 的 5 个浏览器选项卡并一次刷新它们来测试这一点。

以下是我得到的输出:

  • 这里哥们。时间:09:09:04:108
  • 这里哥们。时间:09:09:14:129
  • 这里哥们。时间:09:09:24:160
  • 这里哥们。时间:09:09:34:176
  • 这里哥们。时间:09:09:44:200

时间戳相隔 10 秒。这意味着在前一个请求完成后处理每个请求。这就是同步控制器动作所做的,但我希望异步控制器动作能够在等待时处理请求。为什么 async 在上面的例子中不起作用?我做错了什么?

我在带有 .net 4.5 …

c# asynchronous asp.net-mvc-4

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