好的,我一直在试图解决这个问题,我已经阅读了一些文章,但没有一篇提供我正在寻找的答案。
我的问题是:为什么Task
必须返回 Task 而async Task
不必返回?例如:
public override Task TokenEndpoint(OAuthTokenEndpointContext context)
{
// Code removed for brevity.
return Task.FromResult<object>(null);
}
Run Code Online (Sandbox Code Playgroud)
正如你在那里看到的,那个方法不是async
,所以它必须返回一个任务。
现在,看看这个:
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
// Code removed for brevity...
if(user == null)
{
context.SetError("invalid_grant", "username_or_password_incorrect");
return;
}
if(!user.EmailConfirmed)
{
context.SetError("invalid_grant", "email_not_confirmed");
return;
}
// Code removed for brevity, no returns down here...
}
Run Code Online (Sandbox Code Playgroud)
它使用async
关键字,但不返回任务。这是为什么?我知道这可能是有史以来最愚蠢的问题。但我想知道为什么会这样。
我正在尝试在我构建的 ASP.net core 2.1 应用程序上自动登录以进行调试。
得到错误:
HttpContext 不能为空。
下面的代码位于Startup.cs文件中
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider ServiceProvider)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseCookiePolicy();
CreateRoles(ServiceProvider).Wait();
if (env.IsDevelopment())
{
DeveloperLogin(ServiceProvider).Wait();
}
}
private async Task DeveloperLogin(IServiceProvider serviceProvider){
var UserManager = serviceProvider.GetRequiredService<UserManager<User>>();
var signInManager = serviceProvider.GetRequiredService<SignInManager<User>>();
var …
Run Code Online (Sandbox Code Playgroud) c# asp.net-core-mvc .net-core asp.net-core asp.net-core-identity
例如:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
{{ message }}
</div>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.js'></script>
<script src="app.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
应用程序.ts:
import { Vue } from "vue/types/vue";
let vue = new Vue({
el:"#app",
data:{
text:"hello world"
}
})
Run Code Online (Sandbox Code Playgroud)
cmd后tsc
会生成下面的js
"use strict";
exports.__esModule = true;
var vue_1 = require("vue/types/vue");
var vue = new vue_1.Vue({
el: "#app",
data: {
text: "hello world"
}
});
Run Code Online (Sandbox Code Playgroud)
我希望禁用生成“exports.__esModule = true;” …
例如
每次我在 vscode 中键入ctrl + f5
或ctrl + shift + f5
重新运行 asp.net core api 项目时,它都会打开一个新选项卡。
我希望只是重新启动程序without opening new tab
。
每次需要停止IIS应用程序或池来更新
或者系统会显示The action can't be completed becacuse the file is open in w3wp.exe
我希望像asp.net或mvc一样,你不需要停止IIS来更新。
现在我的方式,我drop a file called app_offline.htm (case sensitive) to my application folder. Let IIS auto stop my application then I update it
从这篇文章iis - 如何在不停止 Web 服务器的情况下通过现有/正在运行的站点更新 ASP.NET Core 应用程序?- 堆栈溢出
我的代码:
select COALESCE (null, '')
from dual
Run Code Online (Sandbox Code Playgroud)
在Oracle中返回null
结果,但是
select COALESCE (null, '')
Run Code Online (Sandbox Code Playgroud)
在SQL Server中返回一个''
结果.
为什么这个结果有所不同?
它们是ANSI标准,应该不一样吗?
+---------+------------+----------+------------+
| prdt_no | order_date | quantity | unit_price |
+---------+------------+----------+------------+
| A001 | 2020-01-01 | 100 | 10 |
| A001 | 2020-01-10 | 200 | 10 |
| A001 | 2020-02-01 | 100 | 20 |
| A001 | 2020-02-05 | 100 | 20 |
| A001 | 2020-02-07 | 100 | 20 |
| A001 | 2020-02-10 | 100 | 15 |
| A002 | 2020-01-01 | 100 | 10 |
| A002 | 2020-01-10 | …
Run Code Online (Sandbox Code Playgroud) 例:
void Main()
{
var dic = new Dictionary<string, object>();
Console.WriteLine(dic is IDictionary<object, object>); //False
Console.WriteLine(dic is IDictionary<dynamic, dynamic>); //False
Console.WriteLine(dic is IDictionary<string, object>); //True
}
Run Code Online (Sandbox Code Playgroud)
字符串也不是对象吗?为什么dic is IDictionary<object, object>
变得虚假.
今天,我的 Visual Studio 2019 团队资源管理器 github push 出现以下错误。
我不知道如何解决这个错误。
错误信息 :
Pushing master
Error encountered while pushing to the remote repository: Git failed with a fatal error.
unable to access 'https://github.com/xxxxxxx.git': error setting certificate verify locations:
CAfile: c:/program files (x86)/microsoft visual studio/2019/community/common7/ide/commonextensions/microsoft/teamfoundation/team explorer/Git/mingw32/bin/curl-ca-bundle.crt
CApath: none
Pushing to https://github.com/xxxxxxx.git
Run Code Online (Sandbox Code Playgroud)
我的 git 版本:
$ git --version
git version 2.17.1.windows.2
Run Code Online (Sandbox Code Playgroud)
我的C:\ProgramData\Git\config
:
[core]
symlinks = false
autocrlf = true
fscache = true
[color]
diff = auto
status = auto
branch = auto …
Run Code Online (Sandbox Code Playgroud) '#if DEBUG' 和 '#endif' 如何删除两个标记之间的内容
例如:在 SQL 字符串下面期望像 '#if DEBUG' 和 '#endif' 来删除/**if DEBUG**/
和/**endif**/
select
id
,name
/**if DEBUG**/
,test1
,test2
/**endif**/
from table
where sDate >= '2021-01-01'
/**if DEBUG**/
and test1 = '123456'
/**endif**/
Run Code Online (Sandbox Code Playgroud)
预期结果 :
select
id
,name
from table
where sDate >= '2021-01-01'
Run Code Online (Sandbox Code Playgroud)
我试过使用正则表达式
(\/\*\*if\sDEBUG\*\*\/)(?<content>)(\/\*\*endif\*\*\/)
(\/\*\*if\sDEBUG\*\*\/)|(\/\/[\w\s\']*)|(\/\*\*endif\*\*\/)
要获取字符串但不起作用,我的代码:
void Main()
{
var input = @"
select
id
,name
/**if DEBUG**/
,test1
,test2
/**endif**/
from table
where sDate >= '2021-01-01'
/**if DEBUG**/
and test1 = …
Run Code Online (Sandbox Code Playgroud) 样本数据:
val1,val2
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3
4,1
Run Code Online (Sandbox Code Playgroud)
异常输出:
val1,val2
1,2
1,3
2,3
4,1
Run Code Online (Sandbox Code Playgroud)
逻辑:
删除相同的 val 排列并保留 min val1 数据。
例如:
删除,1,1
因为它们是相同的。
删除2,1
因为1,2
存在...等
数据 SQL 脚本:
val1,val2
1,1
1,2
1,3
2,1
2,2
2,3
3,1
3,2
3,3
4,1
Run Code Online (Sandbox Code Playgroud)
我运行多个 asp.net core 3.1 应用程序运行 Windows IIS,系统将显示错误HTTP Error 500.35 - ANCM Multiple In-Process Applications in same Process
对于asp.net mvc来说这是可以的,它可以在同一个池中运行多个应用程序。
编辑:
500.35 ANCM 同一进程中存在多个进程内应用程序 工作进程无法在同一进程中运行多个进程内应用程序。
要修复此错误,请在单独的 IIS 应用程序池中运行应用程序。
看起来每个APP都必须有一个池......
c# ×5
asp.net-core ×4
sql ×3
sql-server ×3
iis ×2
.net ×1
.net-5 ×1
.net-core ×1
git ×1
oracle ×1
regex ×1
task ×1
typescript ×1