如何使用Azure Worker Role和OWIN扩展SignalR

SignalR使用Azure Web角色非常精确地扩展。 但是,当我在Azure辅助角色中使用自托管OWIN项目时,SignalR将在添加多个实例时开始出现问题。 为了记录,我的项目使用Redis作为背板。 将Azure辅助角色实例增加到一个以上时,客户端连接将随机失败,并显示错误“ConnectionId格式不正确” 。 我认为这是由于负载均衡导致单个客户端的协商跨越多个服务器时引起的; 我不相信参与协商的多个服务器可以解密数据(DPAPI在封面下?)。 我尝试在app.config中设置 validationKey和decryptionKey,但这似乎没有什么区别; 问题依然存在。 同样,该项目将作为Web角色(IIS)正常工作,但不能作为工作者角色(OWIN自托管)。 假设这是DpapiDataProtectionProvider的问题,我如何确保提供程序在多个服务器/实例之间呈现相同的加密/解密结果? 解 SignalR(DpapiDataProtectionProvider)使用的默认保护提供程序似乎不支持Azure Worker Role scaleout。 通过滚动我自己的示例提供程序,我能够扩展SignalR / OWIN / Azure Worker并且不会收到随机400 HTTP /“ConnectionId的格式不正确”。 请记住,以下示例不会保护/保护令牌。 public class ExampleDataProvider : IDataProtector { public byte[] Protect(byte[] userData) { Trace.TraceInformation(“Protect called: ” + Convert.ToBase64String(userData)); return userData; } public byte[] Unprotect(byte[] protectedData) { Trace.TraceInformation(“Unprotect called: ” + […]

不能声称PosPrinter

我有一个TM-T20爱普生,我正在使用此代码尝试打印:“Hello Printer”消息,我一直跟踪PosPrinter的一些特性: public void ImprintHelloPrinter() { //The Explorer PosExplorer explorer = new PosExplorer(); ////Get the device by its type LOGICAL NAME DeviceInfo device = explorer.GetDevice(DeviceType.PosPrinter, “T20PRINTER”); //Create an instance PosPrinter oposPrinter = (PosPrinter)explorer.CreateInstance(device); //Opening MessageBox.Show(@”Statue : ” + oposPrinter.State.ToString()); oposPrinter.Open(); MessageBox.Show(@”Statue : ” + oposPrinter.State.ToString()); //Checking if its really the printer MessageBox.Show(@”Description : ” + […]

SMTP服务器需要安全连接或客户端未经过身份validation – 仍然无法正常工作

我收到了上述错误。 我看过在线解决方案,我似乎已经做了所有必要但我仍然得到它。 我已经包含了Enablessl = true; 交付方式是网络,我提供了凭据。 我调试了它,用户名和密码似乎是正确的。 using System; using System.Net; using System.Net.Mail; using System.Windows.Forms; namespace SendMail { public partial class MainWindow : Form { #region Private variables private MailMessage _message = new MailMessage(); private EmailSender sender = EmailSender.GetInstance(); private SmtpClient _smtpClient = new SmtpClient(); #endregion public MainWindow() { InitializeComponent(); } private void PrepareMailMessage() { […]

如何在MVC3中获取trace.axd的自定义错误页面?

我的MVC3应用程序显示403,404和500状态代码的自定义错误页面,但浏览到trace.axd会显示以下YSOD: Server Error in ‘/’ Application. Trace Error Description: Trace.axd is not enabled in the configuration file for this application. Note: Trace is never enabled when Details: To enable trace.axd, please create a tag within the configuration file located in the root directory of the current web application. This tag should then have its “enabled” […]

使用RelativeSource和AncestorType进行WPF数据绑定

我试图让一些绑定代码工作。 基本上我想将网格上下文菜单元素的IsEnabled属性与网格中选定行的值绑定。 我有这个工作: 但是我想这样做而且它不起作用。 它没有错误,但只是不禁用菜单项。 知道为什么吗?

Web应用程序中的高效分页

我是Web应用程序中的分页新手。 我在网上搜索了很多关于网页分页的教程(在VS中创建新网站)。 我不能使用当前启用分页的方法,这可以很容易地完成,因为它不高效并从数据库中检索整个数据表。 默认分页 – 只需检查数据Web控件的智能标记中的“启用分页”选项即可实现。 但是,每当查看数据页时,ObjectDataSource都会检索所有记录,即使页面中只显示了它们的一部分。 自定义分页 – 通过仅检索数据库中必须为用户请求的特定数据页面显示的那些记录来提高默认分页的性能。 但是,自定义分页比默认分页需要更多的工作量。 我正在寻找Web应用程序的自定义分页,希望你们能帮助我。 我发现2个链接,我认为可能是自定义分页,但我不确定代码的哪一部分这么说,所以如果你能告诉我哪部分代码实际上使其高效,那将是很好的谢谢! 这2个链接是http://www.codeproject.com/Articles/170921/MvcContrib-Grid-Paging-and-Searching-in-ASP-NET-MV和http://blogs.msdn.com/b/codefx/存档/ 2009/09/07 /如何做-实施-插入-编辑-删除-分页和排序函数function于一个-ASP净gridview的-control.aspx?CommentPosted =真#commentmessage 再次感谢!

C#WinForms ListView项目计数更改事件

WinView中的事件是否会在ListView中的项目数更改时触发? 我试过尺寸和文字 – 奇怪的是他们“sorta”工作但并不总是…… 我尝试触发标签更新列表视图项的计数,因为它更改而无需手动执行一百种方法。

测试超出执行超时时间

我的main.cs代码: public string Generate(int length) { char[] chars = “$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&”.ToCharArray(); string password = string.Empty; Random random = new Random(); for (int i = 0; i < length; i++) { int x = random.Next(1, chars.Length); if (!password.Contains(chars.GetValue(x).ToString())) password += chars.GetValue(x); else i–; } return password; } 我已经制作了测试代码 [TestMethod] [Timeout(1000)] public void RenderingPasswordShouldHaveMaximumSize() { var amountOfCharacters = […]

OpenQA.Selenium.WebDriverException:未知错误:Chrome无法启动:在Linux上通过Selenium执行测试时exception退出

我创建了一个使用Selenium的应用程序,使用.NetCore在Linux上使用它,实际上这是我的代码实现: public class Program { public static async Task Main(string[] args) { //Settings for chrome var chromeOpts = new ChromeOptions(); chromeOpts.AddArgument(“headless”); chromeOpts.AddArgument(“no-sandbox”); //Get assembly path where chrome driver is located string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path = Uri.UnescapeDataString(uri.Path); path = Path.GetDirectoryName(path); var driver = new ChromeDriver(path, chromeOpts, TimeSpan.FromSeconds(180)); } } […]

具有entity framework6的多对多通用更新方法

我在抽象的DatabaseOperations类中有一个用于Entity Framework的通用Update方法: public virtual void Update(T updatedObject, int key) { if (updatedObject == null) { return; } using (var databaseContext = new U()) { databaseContext.Database.Log = Console.Write; T foundEntity = databaseContext.Set().Find(key); databaseContext.Entry(foundEntity).CurrentValues.SetValues(updatedObject); databaseContext.SaveChanges(); } } 但是,这不能处理多对多关系。 通过覆盖TrussSetDatabaseOperations : DatabaseOperations的Update方法可以克服这种多对多更新问题TrussSetDatabaseOperations : DatabaseOperations ,如下所示: public override void Update(TrussSet updatedTrussSet, int key) { if (updatedTrussSet == null) { […]