我有一个 Visual Studio 2017 [ / 2019 ] asp.net 核心 Web 应用程序项目,启用了 docker 支持使用FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base和FROM microsoft/dotnet:2.1-sdk AS build图像。
当我的 f5 调试实例在http://localhost:44301/上启动时,我尝试针对相对 url 发出 HttpClient.SendAsync() 请求/data/some.json以拉入数据,使 localhost 调试能够模拟仅存在于已发布应用程序案例中的安全状态。
当我使用项目的 IISExpress 目标 f5 调试时,这一切正常。当我靠在多克尔F5调试目标针对本地主机相对URL,或完全合格的HttpClient.SendAsync()调用https://localhost:44301/data/some.json和http://localhost:8081/data/some.json路径,生成与消息的例外Cannot assign requested address。如果我更改代码以从远程 url 加载 some.json,例如存储帐户公共 blob 路径,则 f5 调试 Docker 目标不会在此调用中失败。
可以使用https://github.com/myusrn/adncauthexploration.git提供的AzWebApp1项目重现问题,该项目还需要https://github.com/myusrn/KK.AspNetCore.EasyAuthAuthentication.git使用项目引用访问,以启用调试此 nuget 包的内容。使用 localhost f5 iisexpress 目标不会重现该问题。当调试 url 处理命中时,切换到 localhost f5 docker 目标问题重现KK.AspNetCore.EasyAuthAuthentication\Services\EasyAuthWithAuthMeService.cs …
我有一个方案,我计划设置Azure Redis缓存条目的过期时间,以确保我们不保留在特定时间点之后没有任何价值的数据,例如
cache.StringSet(this.cacheId, this.Serialize(), expiry);
Run Code Online (Sandbox Code Playgroud)
同样,其目的是通过包含比实际使用的条目更多的条目来防止Redis缓存性能受到任何影响。
Azure Redis是在条目达到定义的过期时间时刷新条目,还是仅在受到压力以减少内存占用量和后端持久存储时才这样做?
如果我使用 ng2 http 提供者 Observable.toPromise() 支持调用启用了承诺的方法,它会按预期工作,但是当我将它用作承诺链的一部分时,它会在 then 处理程序处理并返回结果之前解析返回的承诺。
让 Observable.toPromise() 在承诺链中工作的任何已知问题或我可能会测试的替代方式以使其成为与承诺链兼容的结果?在 http 请求(promise 链中的最后一项)完成其异步请求并返回结果之前,我被此解析承诺阻止。
例如
this.myService.getSomethingInvolvingingMultiplePromiseCalls().then(result => {
let valueFromSomethingInvolvingMultiplePromiseCalls = result;
}, err => {
console.error('landed in app.component outer promise rejected handler, see output window for details')
})
public getSomethingInvolvingingMultiplePromiseCalls(): Promise<string> {
return this.getSomethingInvolvingPromiseCall().then(resultPromise1 => {
let resultPromise1propertyFoo = resultPromise1.propertyFoo;
return this.getSomethingInvolvingNg2HttpProviderToPromiseCall(resultPromise1propertyFoo);
}
.then(resultPromise2 => {
let resultPromise2propertyBar = resultPromise2.propertyBar;
return resultPromise2propertyBar;
}
}
getSomethingInvolvingNg2HttpProviderToPromiseCall(arg1: string): Promise<string> {
let body = 'some body content leveraging arg1';
let headers = …Run Code Online (Sandbox Code Playgroud) 在asp.net核心Startup.cs配置中,我们提供了一个IHostingEnvironment env参数,该参数公开了env.IsDevelopment()调用,以确定您当前是否正在运行Visual Studio f5调试会话或云部署方案。在功能应用程序中,有一个故事来确定同一件事,因此您可以编写仅在f5调试会话期间运行的代码,例如,填充的(...,ClaimsPrincipal委托人)依赖项注入参数,其中,该参数仅在部署时才通常分配给您声明和角色进入启用云EasyAuth的环境。
我有以下简单的测试,我试图获取 Regex 模式,以便它在没有“.exe”后缀的情况下猛拉可执行文件名称。
看来我的非捕获组设置(?:\\.exe)不起作用,或者我误解了它的工作原理。
无论regex101和regexstorm.net显示了同样的结果和前确认“(?:\。exe文件)”是一个非获取匹配。
关于我做错了什么的任何想法?
// test variable for what i would otherwise acquire from Environment.CommandLine
var testEcl = "\"D:\\src\\repos\\myprj\\bin\\Debug\\MyApp.exe\" /?"
var asmName = Regex.Match(testEcl, @"[^\\]+(?:\.exe)", RegexOptions.IgnoreCase).Value;
// expecting "MyApp" but I get "MyApp.exe"
Run Code Online (Sandbox Code Playgroud)
我已经能够通过使用定义了组名的匹配模式来提取我想要的值,如下所示,但想了解为什么非捕获组设置方法没有按我预期的方式工作。
// test variable for what i would otherwise acquire from Environment.CommandLine
var testEcl = "\"D:\\src\\repos\\myprj\\bin\\Debug\\MyApp.exe\" /?"
var asmName = Regex.Match(Environment.CommandLine, @"(?<fname>[^\\]+)(?<ext>\.exe)",
RegexOptions.IgnoreCase).Groups["fname"].Value;
// get the desired "MyApp" result
Run Code Online (Sandbox Code Playgroud)
/eoq
我一直想做下面的工作,以便有一个简单的故事,用于pandas.DataFrame.someColumnName.unique()在一个内的每一列上执行函数pandas.DataFrame.
df.apply(func=unique, axis=0) # error NameError: name 'unique' is not defined
Run Code Online (Sandbox Code Playgroud)
是否有一些技巧我忽略了这个工作或替代解决方案给出以下类似的东西,但type()在pandas.DataFrame工作中的每个列使用功能.
df.apply(func=lambda x: type(x[0]), axis=0)
Run Code Online (Sandbox Code Playgroud)
请注意,我已经能够进行以下工作,但似乎不是python中的单行for循环的方式,我发现apply语句是一个更好的自我记录实现.
for col in df.columns:
df[col].unique()
Run Code Online (Sandbox Code Playgroud)