小编dra*_*fly的帖子

测量服务器上的请求时间

我想计算两个特定时刻之间的时间:

- start moment would be call to method IDispatchMessageInspector
.AfterReceiveRequest
- end moment would be call to method IDispatchMessageInspector.BeforeSendReply
Run Code Online (Sandbox Code Playgroud)

实际上,我想计算执行服务调用用户代码所需的时间.我认为IDispatchMessageInspector的这两个方法是钩子的好地方.但遗憾的是,我不知道如何将AfterReceiveRequest与相应的BeforeSendReply调用关联起来.

谢谢帕维尔.

wcf

2
推荐指数
1
解决办法
2765
查看次数

WCF服务中的线程

有一段代码:

class WCFConsoleHostApp : IBank
{
    private static int _instanceCounter;

    public WCFConsoleHostApp ()
        {
        Interlocked.Increment(ref _instanceCounter);
        Console.WriteLine(string.Format("{0:T} Instance nr " + _instanceCounter + " created", DateTime.Now));
        }
    private static int amount;

    static void Main(string[] args)
    {            
        ServiceHost host = new ServiceHost(typeof(WCFConsoleHostApp));
        host.Open();
        Console.WriteLine("Host is running...");
        Console.ReadLine();
    }

    #region IBank Members

    BankOperationResult IBank.Put(int amount)
    {
        Console.WriteLine(string.Format("{0:00} {1}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.IsThreadPoolThread) + " Putting...");
        WCFConsoleHostApp.amount += amount;
        Thread.Sleep(20000);
        Console.WriteLine(string.Format("{0:00} {1}", Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.IsThreadPoolThread) + " Putting done");
        return new BankOperationResult { CurrentAmount = WCFConsoleHostApp.amount, …
Run Code Online (Sandbox Code Playgroud)

wcf threadpool

2
推荐指数
1
解决办法
1万
查看次数

IIS Recycle vs ASP .NET Cache

计划回收应用程序池会影响HttpContext.Application/Cache吗?我找不到参考.我猜是的,因为它导致工作进程重新启动,我想确定.我在谈论iis 6.0(w3wp.exe).

谢谢,Pawel

asp.net iis-6

2
推荐指数
1
解决办法
1324
查看次数

ascx/aspx文件的变化 - 它会重置应用程序

ascx/aspx文件的变化 - 它会重置应用程序吗?有时在开发服务器上它们不会导致它,而在实时服务器上我认为它有时会导致它.规则是什么?

谢谢帕维尔

asp.net iis application-pool iisreset

2
推荐指数
2
解决办法
1万
查看次数

NHibernate中的ISession.Save/Update和ITransaction.Commit之间的区别

我有一段代码,可以向实体集合添加元素(一对多关系).这是ISession.Save的版本

        using (ISession session = sessionFactory.OpenSession())
        {
            var package = session.QueryOver<Package>().Where(x => x.ID == selectedPackage).SingleOrDefault();
            foreach(var themeId in selectedThemes)
            {
                var selectedTheme = session.QueryOver<HBTheme>().Where(x => x.ID == themeId).SingleOrDefault();
                if (selectedTheme != null)
                {
                    package.Themes.Add(new PackageTheme() { Package = package, Theme = selectedTheme });
                }
            }
            session.Save(package);
        }
Run Code Online (Sandbox Code Playgroud)

那个版本对我不起作用.正如我用ITransaction编写的测试一样,我将其改为以下内容:

        using (ISession session = sessionFactory.OpenSession())
        using (ITransaction transaction = session.BeginTransaction())
        {
            var package = session.QueryOver<Package>().Where(x => x.ID == selectedPackage).SingleOrDefault();
            foreach(var themeId in selectedThemes)
            {
                var selectedTheme = session.QueryOver<HBTheme>().Where(x …
Run Code Online (Sandbox Code Playgroud)

nhibernate hibernate

2
推荐指数
1
解决办法
1052
查看次数

如何在Eclipse STS中打开Spring Boot示例

我已经下载了Spring引导示例,并且想要在Spring STS中运行其中一个示例,例如:

https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-jsp

但是我不知道如何将其导入Eclipse STS。我尝试了导入向导,从文件系统导入,但是没有进行任何工作((我收到一个错误消息,在给定位置没有项目存在)。

如何在Eclipse STS中运行此样本?

eclipse m2eclipse spring-boot

2
推荐指数
1
解决办法
1万
查看次数

处理web.config文件 - ConfigurationManager的替代方案

前几天我在一些文章中遇到了另一种访问web.config配置的方法.它允许:

  • 提供web.config文件的路径
  • 在运行时修改web.config配置,如:

    config.MySetting = "new value";

  • 从同一IIS中的另一个Web应用程序加载web.config(我不确定)

  • 使用类实例而不是静态ConfigurationManager类来配置

但是这个解决方案让我不知所措:/我记得这篇文章的标题是(类似这样):在Web应用程序中使用应用程序配置的方式.

有人可以遇到这个解决方案,可以用链接刷新我的记忆吗?:)

asp.net web-config

1
推荐指数
1
解决办法
626
查看次数

在.NET中添加斜杠/转义单引号

我正在维护一段连接SQL查询的代码,例如:

string sql = "SELECT* FROM table WHERE column = '" + value + "'";
Run Code Online (Sandbox Code Playgroud)

现在事实证明,如果包含' characted它将破坏SQL Server文本语句.我搜索了类似于PHP addslashes的方法,但没有成功.有Regex.Escape但它没有做到这一点.除了在字符串上调用Replace方法之外,还有其他方法可以解决这个问题吗?:

string sql = "SELECT* FROM table WHERE column = '" + value.Replace("'", "''") + "'";
Run Code Online (Sandbox Code Playgroud)

谢谢,Paweł

.net c# sql-server

1
推荐指数
1
解决办法
5968
查看次数

具有位置的td中的元素:相对重叠在另一个位置上:固定元素

我有一个谜要解决:在我的网页上有一个固定的顶部面板div(类似于gmail的顶部面板).下面,我有一个包含几个单元格的表,最后一个单元格定义如下:

<td class="col-time">
    <div title="?rednie: 180, maksymalne: 186, minimalne: 142" class="hr-avg">
        <span>180 (89%) </span>/ <span class="hr-max">186 (92%) </span>
    </div>
</td>
Run Code Online (Sandbox Code Playgroud)

HR-平均适用的位置:相对风格.

问题是:滚动时,表格隐藏在该顶部面板下(面板的不透明度为1).但让我感到惊讶的是,用位置定义的单元格:相对样式不会隐藏在面板下面.面板和单元格的内容重叠(它产生的效果就像顶部面板仅对该单元格具有不透明度).有人可以解释一下这种行为吗?

谢谢你,帕维尔

html css

1
推荐指数
1
解决办法
1032
查看次数

StringWriter与StreamWriter包装MemoryStream - 区别

我有以下代码:

        byte[] snapthotBytes, snapthotBytes2;
        string stringOutput, stringOutput2;
        IInvestigationDump investigationDump = new HtmlSnapshotDump();
        using (TextWriter writer = new StringWriter())
        {
            investigationDump.Dump(investigation, writer);
            snapthotBytes = Encoding.UTF8.GetBytes(writer.ToString());
            stringOutput = writer.ToString();
        } // end of first implementation

        using (MemoryStream stream = new MemoryStream())
        using (TextWriter writer = new StreamWriter(stream))
        {
            investigationDump.Dump(investigation, writer);
            stream.Seek(0, SeekOrigin.Begin);
            var reader = new StreamReader(stream);
            stringOutput2 = reader.ReadToEnd();
            snapthotBytes2 = stream.ToArray();
        } // end of second implementation

        // stringOutput != stringOutput2 - content wise
        // snapthotBytes != snapthotBytes2 - content …
Run Code Online (Sandbox Code Playgroud)

.net c#

1
推荐指数
1
解决办法
8226
查看次数

PowerShell问题 - 我必须输入./来运行bat文件

我刚刚安装了PHP和Yii Framework.它工作正常,我玩CMD.但过了一段时间我转而使用PowerShell ISE.我导航到Yii文件夹:

cd C:\ dev\yii-1.1.9.r3527\framework

我发出命令:

yiic.bat

我收到一个错误:

PS C:\dev\yii-1.1.9.r3527\framework> yiic.bat
The term 'yiic.bat' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:9
+ yiic.bat <<<< 
    + CategoryInfo          : ObjectNotFound: (yiic.bat:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

但是,当我键入:

./yiic.bat

进入PowerShell窗口,它工作正常.

有没有一种方法来aviod打字./我每次运行时BAT文件?

powershell powershell-2.0

1
推荐指数
1
解决办法
2979
查看次数

使用less来根据参数值生成动态CSS规则并传递mixin

在LESS可以实现这样的目标吗?

.some-button(@className) {
  @className { .actionIcon; }
  tr:hover {
    @className { .actionButton; }
  }
}
Run Code Online (Sandbox Code Playgroud)

我打电话的时候:

.some-button(.edit-action);
Run Code Online (Sandbox Code Playgroud)

预期产量应为:

.edit-action { .actionIcon; }
tr:hover { .edit-action { .actionButton; } }
Run Code Online (Sandbox Code Playgroud)

目前我收到这个"@className {.actionIcon;}中无法识别的输入"错误:

.some-button(@className) {
  @className { .actionIcon; }
  tr:hover {
Run Code Online (Sandbox Code Playgroud)

编辑

我想要实现的另一件事是使用mixin作为mixin参数:

.actionButton(@buttonClassName; @buttonType) {
  @{buttonClassName} { 
    .actionIcon; 
  }
  tr:hover {
    @{buttonClassName} { 
        .actionHoverIcon; 
        @buttonType();
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

和电话是这样的:

.actionButton(~'.row-edit', button-harmful);
Run Code Online (Sandbox Code Playgroud)

其中,纽扣有害是一个mixin.

less

1
推荐指数
1
解决办法
555
查看次数

在ASP .NET MVC 3中重写URL - 在链接中添加*.html后缀

我正在创建简单的应用程序,某种投资组合.我听说在链接中有一个*.html后缀更好,因为当谷歌索引时它会让我获得更好的SEO结果...

无论如何,有没有办法修改默认路由/重写网址,以便我的链接看起来像这样(我使用的波兰语字对我的访问者来说是可读的):

domain.pl/index.html
domain.pl/kontakt.html
domain.pl/oferta.html
domain.pl/sklepy.html
Run Code Online (Sandbox Code Playgroud)

这些链接被转换为一个控制器(如HomeController),但{0} .html链接中的{0}将被用作动作名称?或者甚至更好,我想将{0}从Url映射到英文动作名称,如:

index.html = index action
kontakt.html = contact action
oferta.html = offer action
sklepy.html = shops action
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc iis-7 url-rewriting asp.net-mvc-3

0
推荐指数
1
解决办法
1899
查看次数