我想将MVC MiniProfiler的结果保存到sql server数据库.我分析了一个高负载的mvc4页面,以发现一个棘手的性能问题,这个问题在我们的测试或开发系统上是不可重现的,只是偶尔在生产服务器上发生.
连接迷你探查器的最佳方法是什么?是否有现成的扩展名?
WCF 4.5支持GZIP,无需第三方库或手写扩展.我通过TCP Binding得到它,但找不到通过HTTP绑定使其工作的方法.我的wcf - 服务是自我托管在Windows服务中.
插件:我不允许使用IIS; 我无法切换到任何WCF替换.
这适用于gzip:
binding="customBinding" bindingConfiguration="tcpCompressionBinding" name="tcp"
Run Code Online (Sandbox Code Playgroud)
这就是我目前用于http的内容:
binding="basicHttpBinding" bindingConfiguration="httpBinding" name="http"
Run Code Online (Sandbox Code Playgroud)
该文档并没有真正帮助我:http: //msdn.microsoft.com/en-us/library/dd456789.aspx.
但是,据此,它应该工作:
从WCF 4.5开始,WCF二进制编码器增加了对压缩的支持.使用CompressionFormat属性配置压缩类型.客户端和服务都必须配置CompressionFormat属性.压缩适用于HTTP,HTTPS和TCP协议.如果客户端指定使用压缩但服务不支持它,则抛出协议异常,指示协议不匹配.有关更多信息,请参阅选择消息编码器
var fsw = new FileSystemWatcher(sPath, "*.PPF");
fsw.NotifyFilter = NotifyFilters.FileName;
fsw.IncludeSubdirectories = true;
fsw.Created += FswCreated;
fsw.EnableRaisingEvents = true;
static void FswCreated(object sender, FileSystemEventArgs e)
{
string sFile = e.FullPath;
string[] arrLines = File.ReadAllLines(sFile);
}
Run Code Online (Sandbox Code Playgroud)
这对于大文件失败,因为编写文件时没有完成该过程.该文件是通过网络复制的,所以我不知道文件的大小.需要什么样的同步才能使其稳健?
我将MVC3解决方案升级为MVC4.迁移后,验证程序已损坏.
如果我选择德语作为语言,我的输入日期是"20.03.2013".我在MVC4中得到验证错误,但在MVC3中没有.如果我将格式从"20.03.2013"替换为"20/03/2013",它适用于MVC4,但不适用于MVC3 ;-)
我将当前线程的UI文化设置为德语.ResX值的输出使用正确的语言,因此我知道文化不应该出错.,仅适用于网站本身.错误消息是英文的,但该网站是德语.
我认为这意味着验证器使用了错误的UI文化.
这是我使用的代码.
[Required(ErrorMessageResourceName = "Error_DepartureDate", ErrorMessageResourceType = typeof(Resx.Query))]
public DateTime? DepartureDate { get; set; }
我假设默认模型绑定器有问题,因为渲染的html看起来很好:
data-lang="de" data-mindate="3" data-val="true" data-val-required="Bitte geben Sie das gewünschte Reisedatum des Hinflugs ein." id="DepartureDate" name="DepartureDate" tabindex="3" type="text" value=""
我将Jscript升级到使用Visual Studio 2012(已安装SP1)模板创建新Mvc应用程序时发布的源代码.这没有任何影响.
我有一个CultureModelBinder,它从Session中读取当前的文化,并使用一个小帮助函数设置文化.
public static void UpdateThreadCulture(CultureInfo culture)
{
Thread.CurrentThread.CurrentUICulture = culture;
}
culture文件模型binder是默认的binder.
ModelBinders.Binders.DefaultBinder = new CultureModelBinder(); ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder()); // and many, many more
也许mvc4的执行顺序发生了变化,导致问题?
更新:该项目使用.NET Framework 4.5作为目标.
更新2:
我有一个组合框,用户可以选择16种不同的语言,每种语言都有自己特定的格式.
例如DE-de - > DD.MM.YYYY; en-en - > DD/MM/YYYY; …
什么是增加或减少整数字段的干净,安全的方法.
我将sql server 2012与entityframework 5.x结合使用
我寻找相当于互锁的增量/减量.
我有一个大型的第三方网络服务; reference.cs是33 MB.使用Visual Studio 2017,代理使用XML Serializer,在创建通道时会导致5秒的延迟.我在微软开了一个案例,他们向我展示了如何修改reference.cs以使用Datacontract序列化器.在同一台机器上,通道创建时间为20毫秒,完全符合我的需求.
不幸的是,消息失败并带来微小的差异,微软的支持也无济于事.
有已知的限制吗?我应该寻找的任何模式确保它根本不起作用我应该开始使用HTTP请求重写所有内容?
导致整体延迟的实际方法:
public XmlMembersMapping ImportMembersMapping(string elementName, string ns,
XmlReflectionMember[] members, bool hasWrapperElement, bool writeAccessors,
bool validate, XmlMappingAccess access) {
ElementAccessor element = new ElementAccessor();
element.IsSoap = true;
element.Name = elementName == null || elementName.Length == 0 ? elementName :
XmlConvert.EncodeLocalName(elementName);
}
Run Code Online (Sandbox Code Playgroud) 我创建了正确的模型类型,并不明白它的来源.有任何想法吗?
System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Web.Mvc.HandleErrorInfo', but this dictionary requires a model item of type 'BusinessLogic.Models.ErrorCodeModel'. at System.Web.Mvc.ViewDataDictionary`1.SetModel(Object value) at System.Web.Mvc.ViewDataDictionary..ctor(ViewDataDictionary dictionary) at System.Web.Mvc.WebViewPage`1.SetViewData(ViewDataDictionary viewData) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.ExecuteCore() at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) at System.Web.Mvc.MvcHandler.c__DisplayClass6.c__DisplayClassb.b__5() at System.Web.Mvc.Async.AsyncResultWrapper.c__DisplayClass1.b__0() at System.Web.Mvc.MvcHandler.c__DisplayClasse.b__d() at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
在global.asax.cs中我注册了一个自定义属性:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new Controllers.ExtendendHandleErrorAttribute());
}
定义如下:
public class ExtendendHandleErrorAttribute : …
我有一个应用程序,可以获得随机会话超时.(Windows 2008 R2,.NET 4.0上的IIS 7.5)
我尝试了以下方法:
我现在运行的想法如何发现这个邪恶的错误.有什么建议?我无法在调试器中重现本地计算机上的问题.
一点可能很重要,因为通过tcp套接字连接的第三方系统,从第1页到第2页的移动经常发生会话丢失,有时超过120秒.
我使用ServiceStack.Redis(从最新的源代码构建:https://github.com/ServiceStack/ServiceStack.Redis/tree/master/src).
我做这样的事情:
CacheRecord foundKey = cacheRecords.GetById(p_sParentKey);
...
CacheRecord cacheRecord = cacheRecords.Store(foundKey);
...
redisClient.Expire(p_sParentKey, validityPeriodInMinutes * 60);
Run Code Online (Sandbox Code Playgroud)
我试图调试使用
Console.WriteLine(cacheRecords.GetTimeToLive(p_sParentKey));哪个返回-00:00:01.我分配给validityPeriodInMinutes的值是无关紧要的.
我试过藏汉Expire,ExpireAt,ExpireEntryAt,ExpireEntryIn.我也尝试过这样的事情:
int epoch = (int)(DateTime.UtcNow.AddSeconds(validityPeriodInMinutes) - new DateTime(1970, 1, 1)).TotalSeconds;
redisClient.ExpireAt(p_sParentKey, epoch);
Run Code Online (Sandbox Code Playgroud)
任何的想法?
[Serializable]
public class CacheRecord
{
public CacheRecord()
{
this.Children = new List<CacheRecordChild>();
}
public string Id { get; set; }
public List<CacheRecordChild> Children { get; set; }
}
#endregion
#region public class CacheRecordChild
[Serializable] …Run Code Online (Sandbox Code Playgroud) 我的应用程序使用两个查找表,我想成为内存优化表.
似乎没有属性要声明这个;
是否有可能挂钩表创建过程并查找自定义属性并修改create table命令?
我使用Entity Framework 6.1和Code First.
我寻求一种方法使其声明,所以如果例如EF 6.2或更新的版本支持它官方,我可以放弃我的黑客.
我需要使用perl编写一个套接字服务器,它将在64位linux(2.6x内核)上运行.是否有一个库来支持IO完成端口和Linux上的一些等价物?
我需要听多个端口.8000-8100是否有这样做的聪明方法?
协议必须使用长度字节.
你推荐什么线程库?我在Windows上使用基于协作式多任务处理的threadscheduler编写了类似的东西.我的意思是我想避免为每个套接字创建一个线程来处理超过10,000个同时的连接.
提前致谢.
c# ×6
asp.net-mvc ×3
wcf ×2
.net ×1
asp.net ×1
iis-7 ×1
io ×1
linux ×1
perl ×1
redis ×1
self-hosting ×1
servicestack ×1
sockets ×1
sql-server ×1
t-sql ×1