随机数

Random random = new Random(( int)DateTime .Now.Ticks & 0x0000FFFF);

 

 

如何让ASP.NET Web API显示完整的错误信息,并显示错误堆栈?

在ASP.NET Web  API项目的Application_Start中添加下面的代码:
GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

 

自动清除运行测试用例之后产生的 TestResults垃圾文件夹

在测试项目的配置文件的末尾里添加

<PropertyGroup>

    <TestResultsFolderPath>..\TestResults</TestResultsFolderPath>

</PropertyGroup>

<Target Name="AfterClean">

    <RemoveDir Directories="$(TestResultsFolderPath)" Condition="Exists('$(TestResultsFolderPath)')" />

</Target>

 

或者用msbuild的命令

MSBuild /t:Clean MyProject.csproj

 

@的用法

1字符串换行
 
 
Regular literalVerbatim literalResulting string
"Hello" @"Hello" Hello
"Backslash: \\" @"Backslash: \" Backslash: \
"Quote: \"" @"Quote: """ Quote: "
"CRLF:\r\nPost CRLF" @"CRLF:
Post CRLF"
CRLF:
Post CRLF

 2用语言的保留关键字作为变量名(不是很建议这么做

× object object=null;

√ object @bject=null;

 

 

 返回当前的方法签名

using System.Reflection;

 [Test]
        public void 返回当前方法名()
        {
            StackTrace st = new StackTrace();
            StackFrame sf = st.GetFrame(0);
            MethodBase currentMethodName = sf.GetMethod();
            Console.WriteLine(currentMethodName.ToString());
        }

//Void 返回当前方法名()

  

 

 

编辑器特性

生成构造函数
构造函数 输入ctor 在按TAB键
public const int
public const string
public int property { get; private set; } propg
public static readonly
 
 

web.config

 

移除X-AspNet-Version HTTP头

在web.config里配置

    <!-- 移除X-AspNet-Version HTTP头 -->
    < httpRuntime targetFramework ="4.5 " enableVersionHeader ="false " />

 

   

参考链接:

http://blogs.msdn.com/b/ploeh/archive/2006/07/13/cleaningawaythetestresultsfolder.aspx

 

posted on 2015-11-09 09:38  Cherbim  阅读(614)  评论(0编辑  收藏  举报

这是页脚