小编arc*_*ain的帖子

Android c2dm注册ID格式

我怀疑在发布此帖后我会感到非常愚蠢,但这里有.我有两个主要问题:

1)什么是适用于注册ID的正则表达式?目前我有以下内容,但我无法找到任何文档来支持这是否足够:

'/^[a-z0-9_-]{40,255}$/i'
Run Code Online (Sandbox Code Playgroud)

2)regID包含" - "是否"有效"?我知道android不能担心每种语言 - 在这种情况下是mysql - 用于评论等等,但这让我措手不及.到目前为止,我总是在我的消毒剂中标记出来,因为有可能被用于sql注入.

php regex android android-c2dm

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

正确创建跨域表单身份验证cookie

我只是在两个服务器之间创建一个简单的测试.基本上,如果用户已经过身份验证,我希望能够在应用程序之间传递它们.我改变了键来隐藏它们

我有三个问题:

  1. 跨域应用程序验证cookie的正确方法是什么.例如,当用户登陆successpage.aspx我应该检查什么时?
  2. 以下代码是否对创建跨域身份验证cookie有效?
  3. 我的web.config设置是否正确?

我的代码:

if (authenticated == true)
{
  //FormsAuthentication.SetAuthCookie(userName, false);
  bool IsPersistent = true;
  DateTime expirationDate = new DateTime();
  if (IsPersistent)
    expirationDate = DateTime.Now.AddYears(1);
  else
    expirationDate = DateTime.Now.AddMinutes(300); 

  FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
      1,
      userAuthName,
      DateTime.Now,
      expirationDate,
      IsPersistent,
      userAuthName,
      FormsAuthentication.FormsCookiePath);

  string eth = FormsAuthentication.Encrypt(ticket);
  HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, eth);
  if (IsPersistent)
    cookie.Expires = ticket.Expiration;

  cookie.Domain = ".myDomain.com";
  Response.SetCookie(cookie);
  Response.Cookies.Add(cookie);

  Response.Redirect("successpage.aspx");
}
Run Code Online (Sandbox Code Playgroud)

我的配置:

<authentication mode="Forms">
  <forms loginUrl="~/Default.aspx" timeout="2880" name=".AUTHCOOKIE" domain="myDomain.com" cookieless="UseCookies" enableCrossAppRedirects="true"/>
</authentication> …
Run Code Online (Sandbox Code Playgroud)

asp.net cookies forms-authentication

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

IIS将MVC中的静态文件理解为动态内容

使用httpCompression我重新认识到IIS将MVC中的静态文件理解为动态内容,因此即使勾选" 启用静态内容压缩 ",但不勾选" 启用动态内容压缩 ",IIS也会返回没有压缩的文件.css.js文件:

GET /MVCX/Content/Site.css HTTP/1.1
Host: localhost
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2
Accept: text/css,*/*;
Referer: http://localhost/mvcx/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

HTTP/1.1 200 OK
Content-Type: text/css
Last-Modified: Mon, 05 Dec 2011 12:42:37 GMT
Accept-Ranges: bytes
ETag: "c79895e4bb3cc1:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Mon, 05 Dec 2011 12:44:43 GMT
Content-Length: 1005
Run Code Online (Sandbox Code Playgroud)

但是,如果我勾选" 启用动态内容压缩 ",文件将被压缩:

GET /MVCX/Content/Site.css HTTP/1.1
Host: localhost
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc iis-7 http-compression iis-7.5 asp.net-mvc-3

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

AutoFixture:mock方法不返回冻结的实例

我正在尝试编写这个简单的测试:

var fixture = new Fixture().Customize(new AutoMoqCustomization());

var postProcessingAction = fixture.Freeze<Mock<IPostProcessingAction>>();
var postProcessor = fixture.Freeze<PostProcessor>();

postProcessor.Process("", "");

postProcessingAction.Verify(action => action.Do());
Run Code Online (Sandbox Code Playgroud)

Verify检查失败.
postProcessor.Process的代码是

public void Process(string resultFilePath, string jobId)
{
    IPostProcessingAction postProcessingAction =
        postProcessingActionReader
            .CreatePostProcessingActionFromJobResultXml(resultFilePath);

    postProcessingAction.Do();
}
Run Code Online (Sandbox Code Playgroud)

postProcessingActionReader 是通过构造函数初始化的接口字段.

我期待测试通过,但它失败,事实证明IPostProessingActionCreatePostProcessingActionFromJobResultXml方法返回的实例与返回的实例不同fixture.Freeze<>.

我的期望是,在冻结这个Mock对象后,它会IPostProcessingAction在所需的每个地方注入接口的底层模拟,并使所有模拟方法返回IPostProcessingAction返回同一个对象.

我对mock方法的返回值的期望不正确吗?有没有办法改变这种行为,以便模拟方法返回相同的冻结实例?

moq autofixture

6
推荐指数
2
解决办法
2084
查看次数

以纯模式缓慢启动SQL Reporting Services 2008

我们在当天的第一次报告请求中遇到启动时间较慢,或者在未知的时间段内没有报告请求.在SQL Reporting Server 2005安装中,我们将设置应用程序池以避免回收Reporting Services应用程序.

但是,我的客户端在Windows Server 2008上以纯模式安装了SQL Reporting Server 2008.我找不到IIS安装.我已经检查了SQL Reporting Service配置设置,帮助文件和论坛,并且没有在Native安装上找到此问题的解决方案.

如何以纯模式安装时,如何控制Reporting Services应用程序的回收?

sql-server-2008 reporting-services ssrs-2008

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

LINQ to SQL可以生成包含ISNULL函数的TSQL吗?

我想知道是否有人明确知道LINQ to SQL是否具有生成包含该ISNULL函数的TSQL代码的能力?

我知道??在查询中使用coalesce operator():

from o in Table
where (o.Field ?? 0) > 0
select o
Run Code Online (Sandbox Code Playgroud)

将导致LINQ to SQL发出COALESCE函数:

SELECT [t0].[Field]
FROM [Table] AS [t0]
WHERE (COALESCE([t0].[Field],0)) > 0
Run Code Online (Sandbox Code Playgroud)

并且,?:在查询中使用条件运算符():

from o in Table
where (o.Field == null ? 0 : o.Field) > 0
select o
Run Code Online (Sandbox Code Playgroud)

将导致TSQL包含一个CASE语句:

SELECT [t0].[Field]
FROM [Table] AS [t0]
WHERE (
    (CASE
        WHEN [t0].[Field] IS NULL THEN 0
        ELSE [t0].[Amount]
     END)) > 0
Run Code Online (Sandbox Code Playgroud)

但是,可以强制LINQ to …

c# linq-to-sql

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

SSMS 2012 System.OutOfMemoryException(客户端)和SQL提示符(调试信息包含)

一些背景:我在SSMS 2012中遇到了这个内存异常,因为它与Red Gate的SQLPrompt一起发布(这个例外在同一台笔记本电脑上的SSMS 2008R2中从未发生).

我最初每天都遇到这些异常(SSMS2012和SQLPrompt),这迫使我关闭并重新打开SSMS(以及我正在处理的所有事情).几个月前,我偶然发现了一个支持线程,指出可能的附加组件是原因所以我卸载了我唯一的附加组件(SQL Prompt,但没有卸载开发人员的其他软件包)并且花了很多个月没有一个例外减去System.OutOfMemoryException异常.

一旦SP1在2012年发布,我就应用它并重新安装SQL Prompt(最新版本),看看问题是否已经解决,并且在开发时间的7小时内,我再次受到了臭名昭着的System.OutOfMemoryException的欢迎.

通过所有这些,我一直在打开Red Gate的门票,并在他们看到异常时提交调试日志,但由于内存异常没有明确列出SQLPrompt,他们不会将问题上报给开发团队.在此特定异常之前,SQL Prompt在SSMS 2012 IDE(Visual Studio 2010)中抛出了许多异常(下面列出了一些异常).我相信内存异常是SQL Prompt如何管理缓存数据并占用SSMS可用内存的问题的症状,最终会导致异常.

我已经学会了如何推迟这个问题以及如何重现它,它与两个变量直接相关:

  1. 在SSMS(对象资源管理器和查询窗口)中连接和处理多个实例.即连接到7个实例在2-3小时内净化了异常.
  2. 从多个实例返回结果集.这包括SSMS用于将信息返回到IDE以及返回到各个查询窗口的结果的查询.

我连接到越快的异常的实例越多,这导致SQL Prompt缓存每个实例的所有对象信息.一旦引发内存异常,情况就会降低,直到SSMS完全崩溃(除非我先关闭它).

我所追求的是如何收集更多/更好的信息,以提交给红门以纠正这个问题.这是我需要你帮助的地方.

笔记本电脑:HP Elite书籍8440 RAM:6GB

当前操作系统:Win 7 Enterprise Ed Sp1

以下是SQL Prompt引起的一些异常:

System.ArgumentOutOfRangeException "Specified argument was out of the range of valid values."   

Microsoft.VisualStudio.Text.Implementation.BinaryStringRebuilder.GetLineNumberFromPosition(N/A,N/A)
Microsoft.VisualStudio.Text.Implementation.TextSnapshot.GetLineFromPosition(Microsoft.VisualStudio.Text.Implementation.TextSnapshot,N/A)
Microsoft.VisualStudio.Editor.Implementation.VsTextBufferAdapter.GetLineIndexOfPosition(N/A,System.Int32,System.Int32&,System.Int32&)
RedGate.SQLPrompt.CommonVS.Editor.VSScriptProvider.PositionFromIndex(RedGate.SQLPrompt.CommonVS.Editor.VSScriptProvider,System.Int32)
RedGate.SqlPrompt.Metadata.Script.ScriptProviderBase.GetText(RedGate.SQLPrompt.CommonVS.Editor.VSScriptProvider,System.Int32,System.Int32)
RedGate.SqlPrompt.Engine.NewEngine.SqlPromptEngine.GetCandidates(RedGate.SqlPrompt.Engine.NewEngine.SqlPromptEngine,System.Int32)
RedGate.SqlPrompt.Engine.PromptEngineEmulator.get_GetSuggestions(RedGate.SqlPrompt.Engine.PromptEngineEmulator)
RedGate.SqlPrompt.Engine.AutoCompleter.m_FilterChanged(RedGate.SqlPrompt.Engine.AutoCompleter,RedGate.SqlPrompt.Engine.PromptEngineEmulator,System.EventArgs)
RedGate.SqlPrompt.Engine.PromptEngineEmulator.OnFilterChanged(RedGate.SqlPrompt.Engine.PromptEngineEmulator)
RedGate.SqlPrompt.Engine.PromptEngineEmulator.set_Index(RedGate.SqlPrompt.Engine.PromptEngineEmulator,System.Int32)
RedGate.SqlPrompt.Engine.PromptEngineEmulator.set_CaretPosition(RedGate.SqlPrompt.Engine.PromptEngineEmulator,N/A)
RedGate.SQLPrompt.CommonUI.Editor.EditorWindowBase.SetEngineCaretPosition(RedGate.SQLPrompt.SSMSUI.SSMSEditorWindow,N/A)
RedGate.SQLPrompt.CommonUI.Editor.EditorWindowBase.UpdateUIPrompts(RedGate.SQLPrompt.SSMSUI.SSMSEditorWindow)
RedGate.SQLPrompt.CommonVS.Editor.VSEditorWindow.OnTextViewCommandExec(RedGate.SQLPrompt.SSMSUI.SSMSEditorWindow,RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor,RedGate.SQLPrompt.CommonVS.Editor.CommandExecEventArgs)
RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor.AfterCommandExecute(RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor,RedGate.SQLPrompt.CommonVS.Editor.CommandExecEventArgs)
RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor..(RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor.)
RedGate.SQLPrompt.CommonUI.Utils.ErrorDialog.Do(System.Action)
RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor.(RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor,System.Guid&,System.Uint32,System.Uint32,System.IntPtr,System.IntPtr)
RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor..(RedGate.SQLPrompt.CommonVS.Editor.TextViewMonitor.,System.Guid&,System.Uint32,System.Uint32,System.IntPtr,System.IntPtr)
Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.Exec(N/A,N/A,N/A,N/A,N/A,N/A)

System.ArgumentException    00:05:14.7510000    "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"   

#mMc.#JQub.#OQub(#mMc.#JQub,N/A,System.Uint32,#mMc.#k3ub&)
#mMc.#JQub.#z26.#8Di(#mMc.#JQub.#z26) …
Run Code Online (Sandbox Code Playgroud)

sql ssms redgate ssms-2012 red-gate-sql-prompt

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

在运行时添加nHibernate映射?

背景:

我试图使用nHibernate时遇到映射失败.该应用程序由几个程序集组成.其中一个程序集是一个有用的例程库,另一个是使用该库的应用程序代码.库程序集将自身添加到nHibernate配置中,但由于它不了解其他程序集,因此不会添加它们.我的xml映射文件位于应用程序程序集中.我认为它没有找到它,因为它没有查看应用程序集.

问题: 您是否可以映射到任意程序集中的类而不将其添加到配置中?

如果没有,您可以在运行时添加映射吗?

谢谢

ps我确实确保映射文件被标记为嵌入式资源


更新 - 2009年4月3日

我更改了底层库以允许在初始化时添加程序集.这似乎很有效.

nhibernate

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

Twitter时间表 - 如何包含转推?

这会加载Twitter Feed并显示最后一条推文.

有没有办法在这个函数中包含和检索所有转推?

$(document).ready(function() {
    var url = "http://twitter.com/status/user_timeline/mytwittername.json?count=3&callback=?";
    var lastClass = "";
    $.getJSON(url,
        function(data){
            $.each(data, function(i, item) {
            // check for last tweet
            if (i == (data.length - 1)) {
                lastClass = "class='last'"
            }
            $("#twitter-content ul").append("<li " + lastClass + ">" + item.text.linkify().atify() + " <span class='created_at'>[" + relative_time(item.created_at) + " via " + item.source + "]</span></li>");
        });
    });

    $("#sidebar ul li:last-child").addClass("last");
});
Run Code Online (Sandbox Code Playgroud)

twitter json

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

将自定义属性添加到app.config中的Custom Provider Configuration Section

我正在关注如何在.NET中创建Provider框架的这篇伟大文章

基本上,本文大致解释了如何最终得到如下配置文件:

   <configuration>
     <configSections>
        <section name="data" type="DataProviderConfigurationSection" />
      </configSections>
      <data defaultProvider="MyDataProvider">
         <providers>
            <add name="MydataProvider" type="MyDataProvider"  />
         </providers>
      </data>
   </configuration>
Run Code Online (Sandbox Code Playgroud)

<add/>元素允许你定义一个供应商.

但是,我想知道如何add使用自定义属性扩展条目.

例如:

<providers>
  <add name="MydataProvider" type="MyDataProvider" myProperty="myValue" myProperty2="myValue2" ... />
</providers>
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

c# provider configurationsection

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