小编Ale*_*lex的帖子

在 .net 核心应用程序中获取 Docker 容器 IP

使用 获取容器本身内当前 docker 容器 IP 地址的最佳方法是什么.net core

我尝试将我的容器注册到Consul托管在 Docker 主机上的服务器(而不是作为容器),并且我需要在启动时获取容器 IP 地址以进行注册。因为 IP 地址在任何容器启动时都会发生变化,所以我不能将其硬编码到appsettings.json. 我跟着这个教程。当谈到这一部分时:

// Get server IP address
var features = app.Properties["server.Features"] as FeatureCollection;
var addresses = features.Get<IServerAddressesFeature>();
var address = addresses.Addresses.First();

// Register service with consul
var uri = new Uri(address);
var registration = new AgentServiceRegistration()
{
     ID = $"{consulConfig.Value.ServiceID}-{uri.Port}",
     Name = consulConfig.Value.ServiceName,
     Address = $"{uri.Scheme}://{uri.Host}",
     Port = uri.Port,
     Tags = new[] { "Students", "Courses", "School" }
};
Run Code Online (Sandbox Code Playgroud)

接收到的 …

docker consul asp.net-core

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

.net core + Docker: The remote certificate is invalid according to the validation procedure

What is the correct way for multiple Windows containers running a .net core application to trust each other's HTTPS certificates?

I have the following setup:

  • Container A is running a REST service which is required by Container B
  • Container B calls the REST service with an HttpClient
  • Container B does something with the result

The problem is, that when B calls A, I got a The remote certificate is invalid according to the validation procedure. exception. This is the …

https docker asp.net-core-2.0 windows-container

5
推荐指数
0
解决办法
7514
查看次数

设置 IIS10 以提供预压缩文件

我的 angular2 项目为我的 web 应用程序构建了预压缩的 gzip 文件,但我的 IIS 只提供普通的“.js”文件而不是压缩的“.gzip”文件。我的浏览器愿意接受 gzip。

IIS 允许 gzip 响应的正确设置是什么?

我已经搜索了 google/SO/SU,但只找到了非“预压缩”内容的解决方案。

iis gzip http-compression angular

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

字符串到字节数组(到字符串到 XML)并再次返回

我知道有 100 万个关于“字符串 - 字节数组”转换的问题,但没有一个适合我的问题。

为了安装我的软件,我需要保存用户的一些信息(服务器地址、用户 ID、密码等)。其中一些信息需要受到保护(使用 DPAPI 加密)。为此,我必须将string( SecureString)转换为byte[]

public static byte[] StringToByte(string s)
{
    return Convert.FromBase64String(s);
}
Run Code Online (Sandbox Code Playgroud)

我遇到的第一个问题。如果字符串长度不是 4 ( s.lenght % 4 == 0)的倍数,我会收到“Base-64 字符数组的长度无效”错误。我读过我可以(必须)在末尾添加“=”,string但其中一些字符串可能是密码(可能包含“=”)。我需要将(加密的)数据存储在 XML 文件中,为什么我不能使用 Unicode 编码(我不知道为什么,但它破坏了 XML 文件......因为我认为是编码)。

作为最后一步,我必须回到在应用程序启动时获取存储数据的方法。

你们中有人可以帮我解决这个问题吗?我不在乎 XML 中的输出,只要它是“可读的”。

最好的问候亚历克斯

c# string bytearray type-conversion

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

Angular2 - 多个模块的共享布局

我用不同的模块构建了一个 Angular 应用程序。每个模块处理不同的任务。在我的登陆页面上,用户应该登录或注册。这是一个非常精简的布局,没有任何导航。在我的功能模块(登录后可以访问)上,用户可以执行任务和搜索信息。

我的主要问题是,我的功能模块应该共享相同的布局(带有导航、工具栏等),而我的 AuthModule 不应具有相同的布局。下图应该说明我试图实现的目标。

在此处输入图片说明

每个模块(身份验证和功能)都有自己的 RoutingModule 和不同的组件集。对 Layout2 和 FeatureModules 的访问受 AuthService/AuthGuards 保护。

我已经为基于组件的设置找到了很好的解决方案(/sf/answers/2835616311/https://stackblitz.com/edit/angular-multi-layout-example?file=app%2Fapp。 routing.ts ) 但不适用于基于模块的模块。我想延迟加载功能模块,这不能应用于我找到的给定解决方案(至少它不适用于模块)。

我可以做些什么来共享模块之间的布局,或者换句话说“在布局组件中加载模块”?

我目前的代码片段是:

应用组件

<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)

用户区组件

<mat-toolbar color="primary" class="mat-elevation-z2" *ngIf="(auth.account$ | async) as account">
    <button mat-button class="pull-left" [disabled]="!account" (click)="sidenav.toggle()">
        <i class="fa fa-navicon" aria-hidden="true"></i> SiteName
    </button>

    <button mat-button class="pull-left ml-3 pull-left" routerLink="/settings/profile">
        <img [src]="account.userID | avatar" class="rounded-circle mr-1" width="30" height="30">
        <span class="d-none d-sm-inline"> {{account.name}}</span>
    </button>

    <button id="logoutButton" mat-button class="pull-right" routerLink="/auth/logout">
        <i class="fa fa-power-off" aria-hidden="true"></i><span class="d-none d-sm-inline"> Logout</span>
    </button>
</mat-toolbar>

<mat-sidenav-container …
Run Code Online (Sandbox Code Playgroud)

layout routing module angular

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

.css.br 的 MIME 类型?

.css.br 文件的正确 MIME 类型是什么?对于“.css”,它是“text/css”,对于“.js.br”,它是“application/x-br”(至少它对我有用)。但是“.css.br”该用什么?

mime-types brotli

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