我试图在Microsoft指南之后在Visual Studio代码中设置TypeScript表达/节点应用程序,但是将其更改为使用TypeScript,但是在使用typings我安装类型定义时,我似乎必须安装比指南更多的包.
我正在运行以下一对命令:
typings install node --ambient --save
typings install express --ambient --save
Run Code Online (Sandbox Code Playgroud)
但是,尝试使用这些包进行构建会产生以下类型的错误:
error TS2307: Cannot find module 'serve-static'.
Run Code Online (Sandbox Code Playgroud)
对于以下类型:
我可以通过安装所需的打字来解决这个问题,但似乎某些打字应该自己做.
我想检查一下我是否错过了自动引入依赖关系或者指南是否过时的基本步骤?
如果它是相关的,我的tsconfig.json:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"outDir": "bin",
"sourceRoot": "src"
},
"exclude": [
"node_modules",
"typings/browser.d.ts",
"typings/browser"
]
}
Run Code Online (Sandbox Code Playgroud)
我的tsc是1.8.7版本,我在全球范围内安装了打字稿.
我无法让ASP Identity按需刷新存储在cookie中的身份.
在Startup.Auth.cs文件中,cookie设置为重新生成,如下所示:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<QuizSparkUserManager, QuizSparkUser, int>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentityCallback: ((manager, user) => manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie)),
getUserIdCallback: ((claimsIdentity) => int.Parse(claimsIdentity.GetUserId())))
}
});
Run Code Online (Sandbox Code Playgroud)
但是我无法弄清楚如何刷新User.Identity代码中的内容,即在我需要刷新时强制刷新身份cookie.
我希望能够以编程方式使用重新生成身份回调,这可能吗?
我的问题与此类似:如何使用Asp.Net Identity 2将用户添加到角色后使.AspNet.ApplicationCookie无效?
但是我想刷新而不是使cookie无效.
编辑
在查看链接的问题后,我尝试了以下(没有完整的错误处理):
IOwinContext context = Request.GetOwinContext();
QuizSparkSignInManager manager = context.Get<QuizSparkSignInManager>();
ClaimsIdentity newIdentity = manager.CreateUserIdentity(manager.UserManager.FindById(User.Identity.GetUserId<int>()));
AuthenticateResult authenticationContext =
await context.Authentication.AuthenticateAsync(DefaultAuthenticationTypes.ApplicationCookie);
if (authenticationContext != null)
{
context.Authentication.AuthenticationResponseGrant = new AuthenticationResponseGrant(
newIdentity, authenticationContext.Properties);
}
bool …Run Code Online (Sandbox Code Playgroud) 在他有关C#async / await中的线程使用的博客文章(http://blog.stephencleary.com/2013/11/there-is-no-thread.html)中,Stephen Cleary详细介绍了如何不使用线程来处理真正的线程。异步操作,例如文件I / O,Web请求等(从现有线程(例如I / O线程)借来的时间除外)
从该帖子看来,当操作系统为Windows时,BCL似乎将使用重叠的I / O或I / O完成端口将操作传递给操作系统。
我的问题是,是否将相同的“无线程”且非阻塞的异步操作模型应用于其他操作系统(主要是Linux的Mono)的C#实现?
如果是这样,那么BCL与OS进行通信的通道是什么,因为IOCP(和重叠的I / O)似乎是Win32 API所特有的?
另外,据推测,一旦到达驱动程序,无论OS是什么,操作都是异步的?