pipe操作员与链接相比,我有点困惑map.以下两个例子在功能上是否相同?管道功能的目的或优点是什么?
const name = ajax
.getJSON<{ name: string }>("/api/employees/alice")
.pipe(
retry(3, 1000),
map(employee => employee.name),
catchError(error => of(null))
);
const name = ajax
.getJSON<{ name: string }>("/api/employees/alice")
.let(retry(3, 1000))
.map(employee => employee.name)
.catch(error => Rx.Observable.of(null));
Run Code Online (Sandbox Code Playgroud) 我的代码在通过FTP下载大文件30分钟后遇到超时异常.服务器是在Windows上运行的FileZilla.我们有一个配置了选项Enable FTP over SSL/TLS support (FTPS)并Allow explicit FTP over TLS启用的SSL证书.我可以访问服务器和FileZilla配置,但看不到任何可能导致此行为的内容.下面是在Windows 2012 Server Machine上运行在.NET 4.6.2上的源代码.它可以从FTP服务器下载文件,但如果文件下载时间超过30分钟,则会在30分钟后超时(如下所列).
作为测试,我使用从同一客户端PC运行的FileZilla Client,同时从同一服务器端点下载多个大文件,以便每个文件的下载花费超过30分钟来完成.此方案中未发生任何错误.
我在StackOverflow以及Google上搜索过,但没有任何有希望的东西出现.如果有人有一些关于在哪里看(服务器端或客户端)的提示,我将非常感激.
public class FtpFileDownloader
{
// log4net
private static readonly ILog Logger = LogManager.GetLogger(typeof(FtpFileDownloader));
public void DownloadFile()
{
// setting the SecurityProtocol did not change the outcome, both were tried. Originally it was not set at all.
// ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, …Run Code Online (Sandbox Code Playgroud) 我正在使用一个包含信用交易的表格,我想要显示销售时花费的信用额度.
在表中:
Credits由实体使用唯一实体代码添加(记录在列中GivenByUserCode)GivenByUserCodeis null).如果用户2018-01-02在报表上进行购买,则使用上述数据作为示例,应显示源自的所有这些信用BM01.增加的复杂性在于购买可以分为多个添加,请参阅购买2018-02-03分为3个添加.
我认为解决方案将与使用cte和over有关,但我没有使用这些的经验.我确实在SqlServerCentral上发现了类似(不相同)的问题.
任何帮助/方向将是最受欢迎的.
DECLARE @CreditLogs TABLE(CreditLogId int not null identity(1,1), Credits INT NOT NULL, OccurredOn DATETIME2(7) NOT NULL, GivenByUserCode VARCHAR(100) NULL)
INSERT INTO @CreditLogs (Credits, OccurredOn, GivenByUserCode) VALUES
(10, '2018-01-01', 'BM01')
, (10, '2018-01-01', 'BM01')
, (-10, '2018-01-02', NULL)
, (-5, '2018-01-04', NULL)
, (5, '2018-02-01', 'SP99')
, (40, '2018-02-02', 'BM02')
, (-40, '2018-02-03', …Run Code Online (Sandbox Code Playgroud) 我想保护我的应用程序中的特定文件夹和资源,这些文件夹和资源位于我的mvc应用程序的路由之外.我希望这些资源仅供经过身份验证的用户使用(只要经过身份验证,该角色就不具备这些角色).
最初似乎UrlAuthorizationModule就是答案.我按照本文,了解IIS 7.0 URL授权,我可以让模块工作,因为它响应了中的配置元素web.config.
我目前的问题是,我认为它是基于IIS中的匿名用户而不是asp.net身份中经过身份验证的用户制定的规则.
我使用标准html文件进行测试,而不是尝试加载脚本,因为这也会在MVC管道之外加载.
Visual Studio 2015.
.net 4.6.2Web项目Individual User Accounts添加 web.config
<configuration>
...
<location path="Data">
<system.webServer>
<security>
<authorization>
<clear/>
<add accessType="Deny" users="*"/>
<add accessType="Allow" users="?"/>
</authorization>
</security>
</system.webServer>
</location>
...
</configuration>
Run Code Online (Sandbox Code Playgroud)
添加到文件夹结构
/Data/Protected.html // this file just has some basic Hello World content to display so …Run Code Online (Sandbox Code Playgroud) asp.net asp.net-mvc asp.net-authorization asp.net-identity-2
我在Visual Studio 2017中使用AngularJS创建了一个.Net Core项目,但是当我尝试创建服务时,我收到错误
对装饰器的实验性支持是一个在将来的版本中可能会发生变化的功能.设置'experimentalDecorators'选项`以删除此警告.
我检查了几个链接,例如编辑tsconfig.json以及link1和link2等链接
现在我的tsconfig.json如下所示
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"experimentalDecorators": true,
"allowJs": true,
"noEmit": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
},
"include": [
"app/**/*"
],
"files": [], //add a "files" array (in my case empty)
"exclude": [
"node_modules"
],
"typeAcquisition": {
"enable": true // helps fuel better js intellisense
}
}
Run Code Online (Sandbox Code Playgroud)
但我仍然看到错误,现在我一无所知.
我们使用MVC 5.2和ASP.NET Identity框架进行身份验证,使用表单身份验证屏幕(用户和密码组合),并使用cookie保留身份.我在Identity框架的启动方法中配置了将身份验证cookie的到期时间设置为30天,当用户选择"记住我"(IsPersistent = true)时,这种方法很好.当IsPersistent = false(用户选择不选择"记住我")时,默认情况下会创建会话cookie.此会话cookie在Internet Explorer和FireFox中运行良好,当浏览器关闭时,cookie将丢失.在Chrome和Safari(也可能是其他浏览器)中,有一些选项可以确保会话cookie不会丢失,
我想要一个解决方法,以确保会话cookie不会永久保留,但会在一小时内丢弃.我可以通过检查帐户是否在X分钟/小时内没有活动来实现这一点,并且用户从未选择"记住我",然后如果超过该时间跨度,则用户身份被下一个请求"拒绝".
有没有人在他们的ASP.NET身份实现中创建了一个解决方案,以确保在X时间之后会话cookie在后端过期,或者是否有更好的方法来解决这个限制?也许可以使用CookieAuthenticationProvider的自定义实现来执行此操作,或者将过期日期/时间交给用户声明,可以在ValidateIdentity流程中的某处进行检查?
任何想法都会很棒.提前谢谢你,-Igor
编辑 - 更多信息:我的身份验证实现有2种基本"模式"(目前无法想到更好的词).我的实现是一个简单的用户名/密码表单,带有一个"记住我"的复选框.复选框值传递给AuthenticationProperties对象的IsPersistent属性,该属性将传递给AuthenticationManager :: SignIn方法.
用户想要"记住我",这会创建一个长期存在的cookie,使用滑动过期设置30天.这使用户能够在浏览器会话之间保持身份验证,并且由于不活动而没有超时,除了不访问该站点超过30天.我的owin启动方法中的设置反映了cookie的到期时间为30天(CookieAuthenticationOptions.ExpireTimeSpan设置为30天).无论浏览器平台如何,这都有效(据我所知).
用户不想"记住我",预期的行为应该是创建会话cookie,当浏览器关闭时,会话cookie将从浏览器中删除.这应该确保下次启动浏览器时未对用户进行身份验证.当像公共计算机一样使用共享设备时,这一点尤其重要.问题是并非所有浏览器都会删除会话cookie,如果启用了浏览器设置,有些人会故意将它们留下(Chrome就是一个很好的例子).会话cookie没有到期日期/时间,因此CookieAuthenticationOptions.ExpireTimeSpan在此处没有任何影响.这是我在寻找建议的地方,因为我相信我不能成为第一个遇到此问题的人.可能有一种方法可以使这种行为更安全,因为替代方法是什么也不做,并且可能在浏览器上留下会话cookie(永不过期!).
我试图通过ng build --prod将我的角度代码编译到生产模式并且它成功但在浏览器中我得到错误:
ERROR p {__zone_symbol__error: Error: Uncaught (in promise): Error: NullInjectorError: No provider for t!
Run Code Online (Sandbox Code Playgroud)
错误:NullInjectorError:...,...}
当我只运行构建时,html工作正常.
我试过git hub上提到的几个链接:
https://github.com/angular/angular/issues/19219 https://github.com/angular/angular-cli/issues/6851
没有多大帮助.
附加我的Package.json文件内容:
{
"name": "xxx",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"pree2e": "webdriver-manager update --standalone false --gecko false",
"e2e": "protractor",
"build": "ng build && node server.js",
"dev": "ng build -w & nodemon server.js --watch dist --watch server",
"production": "ng build --prod & node server.js …Run Code Online (Sandbox Code Playgroud)我想解决这个问题:Angular 5 - 模板驱动的形式
输入字段具有类型电子邮件.例:
<input type="email" [(ngModel)]="model.email" #email="ngModel" email />
Run Code Online (Sandbox Code Playgroud)
我想验证这个字段.但它不应该是必填字段.如果验证不为空,则应仅启动验证.如果该字段为空,则可以使用.否则,在电子邮件地址正确之前,应显示错误消息.
这不是真正的工作:
*ngIf="email.untouched && email.invalid"
Run Code Online (Sandbox Code Playgroud)
那么,我该如何验证电子邮件字段?我想念"不空"这样的状态.
任何提示?
我从存储过程中获取XML输出.我想要做的是获取XML并通过ASP.NET传递出来:
public XmlDocument GetPunchListXml(string communityDesc)
{
try
{
using (connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand("GetPunchList", connection))
{
command.CommandType = CommandType.StoredProcedure;
SqlParameter parameter1 = new SqlParameter("@communityDesc", SqlDbType.VarChar);
parameter1.Value = communityDesc;
parameter1.Direction = ParameterDirection.Input;
command.Parameters.Add(parameter1);
var doc = new XmlDocument();
var reader = command.ExecuteXmlReader();
if (reader.Read())
{
doc.Load(reader);
}
return doc;
}
}
}
finally
{
connection.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
但我一直收到这些错误:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The 'ObjectContent`1' type failed to serialize the response body for …Run Code Online (Sandbox Code Playgroud) 我在Chrome开发者工具中玩耍,并尝试了以下代码:
let = 1;
let x = 2;
console.log(let); // 1
console.log(x); // 2Run Code Online (Sandbox Code Playgroud)
如果我将“ let”替换为“ var”,则以上代码将不起作用。
我假设这let = 1与相同var let = 1。如果是这样,不let x = 2应该翻译成1 x = 2错误吗?
angular ×4
c# ×3
asp.net ×2
asp.net-mvc ×2
sql-server ×2
.net ×1
angular5 ×1
filezilla ×1
ftp ×1
javascript ×1
rxjs ×1
sql ×1
typescript ×1
xml ×1