我有
epilogue.resource({
model: db.Question,
endpoints: ['/api/questions', '/api/questions/:id'],
associations: true
});
Run Code Online (Sandbox Code Playgroud)
所以,当我点击时/api/questions,我会恢复与资源的所有关联.在某些情况下,我是否可以通过某些内容来获取关联?或者我应该创建一个新的端点:
epilogue.resource({
model: db.Question,
endpoints: ['/api/questions2', '/api/questions2/:id']
});
Run Code Online (Sandbox Code Playgroud) 我有一个数据库,用于保存某个街道上每个房子的居民.我有一个'房子视图'php网页,当使用'post'给出房屋号码时,可以显示个人房屋和居民.我还有一个"街景"网页,列出了房屋清单.我想知道的是,你是否可以在街景上找到链接到房屋视图的链接并同时发布房屋号码,而无需为每个房间设置表格?
问候
我试图从公共URL下载一个大文件.它起初似乎运行良好,但1/10计算机似乎超时.我最初的尝试是使用,WebClient.DownloadFileAsync但因为它永远不会完成我回到使用WebRequest.Create并直接读取响应流.
我使用的第一个版本WebRequest.Create发现了同样的问题WebClient.DownloadFileAsync.操作超时,文件未完成.
如果下载超时,我的下一个版本会添加重试.这是奇怪的.下载最终完成1次重试以完成最后7092字节.因此,文件的下载大小完全相同但文件已损坏且与源文件不同.现在我希望腐败在最后7092字节,但事实并非如此.
使用BeyondCompare我发现损坏的文件中缺少2个字节块,总计缺少7092个字节!在下载超时并重新启动之前,这个丢失的字节位于1CA49FF0和1E31F380之前.
这可能会发生什么?有关如何进一步追踪此问题的任何提示?
这是有问题的代码.
public void DownloadFile(string sourceUri, string destinationPath)
{
//roughly based on: http://stackoverflow.com/questions/2269607/how-to-programmatically-download-a-large-file-in-c-sharp
//not using WebClient.DownloadFileAsync as it seems to stall out on large files rarely for unknown reasons.
using (var fileStream = File.Open(destinationPath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
long totalBytesToReceive = 0;
long totalBytesReceived = 0;
int attemptCount = 0;
bool isFinished = false;
while (!isFinished)
{
attemptCount += 1;
if (attemptCount > 10) …Run Code Online (Sandbox Code Playgroud) 如果在调用方法时它们可能不存在,它们的用途是什么?
这是否意味着您可以在动态对象上动态创建方法?
这有什么实际用处?
我有一个webforms网站,正在调用我们正在开发的新MVC6网站.用户将使用表单身份验证在webforms网站上一直登录,然后重定向到新的MVC6网站.我知道在MVC6中我应该使用Cookie身份验证,但无法让它解密cookie.我怀疑它是关于web.config和machinekey的变化,但我真的被卡住了.
这就是我所做的.
我已按如下方式设置了cookie身份验证
app.UseCookieAuthentication(options =>
{
options.CookieName = "MyWebformsCookie";
options.AutomaticAuthenticate = true;
options.AuthenticationScheme = "Cookies";
options.TicketDataFormat = new MySecureDataFormat();
options.DataProtectionProvider = new MyDataProtectionProvider();
//options.CookieDomain = "localhost";
});
Run Code Online (Sandbox Code Playgroud)
课程如下
public class MySecureDataFormat : ISecureDataFormat<AuthenticationTicket>
{
public string Protect(AuthenticationTicket data)
{
return string.Empty;
}
public string Protect(AuthenticationTicket data, string purpose)
{
return string.Empty;
}
public AuthenticationTicket Unprotect(string protectedText)
{
return null;
}
public AuthenticationTicket Unprotect(string protectedText, string purpose)
{
var ticket = FormsAuthentication.Decrypt(protectedText);
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
正在读取cookie,并调用Unprotect方法,但随后在FormsAuthentication.Decrypt方法上出现错误并出现错误
System.Web.dll中出现"System.Web.HttpException"类型的异常,但未在用户代码中处理
其他信息:无法验证数据.
Stack = …
通过甜甜圈缓存,我指的是Scott Guthrie的博客文章很棒.
有谁知道这是否正常?
我真的很想在我正在工作的商店内推动TDD开发.那里的许多老年人没有使用单元测试或进行了数据库测试.
我很乐意带来一些好的论据,培训书籍,可能的教练来缓解过渡.
当SQL Server 2005碰巧达到IDENTITY列的最大值时会发生什么?它是从一开始就开始重新填补空白吗?
SQL Server 2005发生时的行为是什么?
在WIF之前,Application_PostAcquireRequestState是创建自定义标识的好地方,但需要大量框架来确保您正在进行的每种类型的身份验证都已正确映射.通过自定义标识,我的意思是继承自Identity的类,例如下面的SomeIdentity,这样我们就可以拥有一个特定的属性,我们可能需要所有经过身份验证的用户拥有.
PostAcquirerequestState仍然可用,但是有很多新方法可以挂钩进行身份验证.此外,支持多种身份验证方法时,旧方法变得复杂.
我想知道在WIF中是否有比下面更好的方法来实现这一点.主要是我想将处理映射声明的代码分离出来.这个想法是代码对于其他身份验证类型/提供者而言是不同的,因为它检索该属性值的方式可能不是来自诸如SAML的声明,而是来自其他地方的其他类型的身份验证方法.我Kentor.AuthServices目前正在使用SAML支持.虽然可能有不同的代码用于根据提供程序映射这些值,但最终结果是已创建SomeIdentity实例并且将设置SomeProperty和其他属性.这样,应用程序的其余部分总是可以依赖/假设已经处理过.
我的MVC项目想出了一个AccountController即有ExternalLoginCallback其隐含的可能是,当外部认证结束一个良好的钩的名字(这对我SAML是"外部"认证).但是,在SAML身份验证期间/之后的任何时候似乎都没有受到攻击.
可能答案是我们仍然需要以旧方式将它们拼凑在一起,但我希望WIF有一些更好的框架钩子来使这更容易.
public sealed class SomeIdentity : Identity
{
...
// Some custom properties
public string SomeProperty { get;set;}
}
protected void Application_PostAcquireRequestState(object sender, EventArgs e)
{
...
identity = new SomeIdentity(id, userId);
// map a claim to a specific property
identity.SomeProperty = ...Claims[IdpSomePropertyKey];
///...
GenericPrincipal newPrincipal = new GenericPrincipal(identity , null);
HttpContext.Current.User = newPrincipal;
System.Threading.Thread.CurrentPrincipal = newPrincipal;
}
Run Code Online (Sandbox Code Playgroud)
现在我正在使用WIF,我应该在哪里放置特定于特定身份验证类型的代码(即Kentor.AuthServices SAML)来创建自定义SomeIdentity?
我的想法是,SomeIdentity将是我的应用程序中随处使用的标识类,但是填充它的属性的代码将需要专门针对每种身份验证类型编写,例如使用SAML来提取声明并使用它们的值来设置proeprties.即它是映射发生的地方.
我正在测试[Authorize]属性,但如果用户尚未登录,我无法重定向到登录页面(Chrome检查员返回401).
这是我在我的Controller中登录的代码(非常简单).
if (model.UserName == "admin" && model.Password == "test")
{
var claims = new[] { new Claim("name", model.UserName), new Claim(ClaimTypes.Role, "Admin") };
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
await HttpContext.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity));
return RedirectToAction("Index", "Home");
}
Run Code Online (Sandbox Code Playgroud)
这是我在Startup.cs中用于登录的配置:
app.UseCookieAuthentication(options =>
{
options.AutomaticAuthenticate = true;
options.LoginPath = new PathString("/Account/Login");
});
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢!!
c# ×4
.net ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
associations ×1
c#-4.0 ×1
caching ×1
cookies ×1
download ×1
encryption ×1
epilogue ×1
file ×1
html ×1
identity ×1
javascript ×1
limits ×1
php ×1
sequelize.js ×1
sql ×1
tdd ×1
web ×1
webrequest ×1
wif ×1