.andSelf()
.live()
.die()
.error()
.load()
.unload()
.size()
.toggle()
app.UseStaticFiles(new StaticFileOptions
{
OnPrepareResponse = ctx =>
{
const int durationInSeconds = 60 * 60 * 24 * 365; //一年
ctx.Context.Response.Headers[HeaderNames.CacheControl] =
"public,max-age=" + durationInSeconds;
}
});
app.UseRouting();
<a href="http://..." target="_blank" rel="opener">Link</a>
$(".hlkPrint").click(function () {
$("form").setPostDataToStorage();
$("form").attr("rel", "opener");
$("form").attr("target", "_blank");
$("form").attr("action", "xxxxx.aspx");
$("form").submit();
});
-- 假設 OrderDetailId 是 varchar(20)
-- OrderDetail 有千萬筆資料
Select * from OrderDetail where OrderDetailId= N'20220923084533'
-- 結果跑超級久 (未使用 PK 找,掃整個 table)
Select * from OrderDetail where OrderDetailId= '20220923084533'
-- 結果一下就出來 (使用 PK 找)
-- **資料庫設計最好以數值來當 key 比較好
var newFilename = filename.Replace("..", "").ValidFilenameCharacters();
static System.Security.Cryptography.RandomNumberGenerator RandomNumberGenerator = null;
/// <summary>
/// 回傳大於等於 0 小於 1
/// </summary>
/// <returns></returns>
public static double NextDouble()
{
if (RandomNumberGenerator == null || LastRandomGenerateTime < DateTime.Now.AddMinutes(-1))
{
RandomNumberGenerator = System.Security.Cryptography.RandomNumberGenerator.Create();
}
// Generate four random bytes
byte[] four_bytes = new byte[4];
RandomNumberGenerator.GetBytes(four_bytes);
// Convert the bytes to a UInt32
uint scale = BitConverter.ToUInt32(four_bytes, 0);
// And use that to pick a random number >= min and < max
// 0 <= (scale / (uint.MaxValue + 1.0)) < 1
return scale / (uint.MaxValue + 1.0);
}
/// <summary>
/// 回傳值介於 min ~ (max - 1)
/// </summary>
/// <param name="min"></param>
/// <param name="max"></param>
/// <returns></returns>
public static int GetRandomInt(int min, int max)
{
if(max < min)
{
throw new Exception("最大值不可小於最小值");
}
// Generate four random bytes
byte[] four_bytes = new byte[4];
RandomNumberGenerator.GetBytes(four_bytes);
// And use that to pick a random number >= min and < max
return (int)(min + (max - min) * NextDouble()); //因為 NextDouble 會小於 1,所以用無條件捨去.
}
/// <summary>
/// 產生 0 ~ (max - 1) 的亂數
/// </summary>
/// <param name="max"></param>
/// <returns></returns>
public static int GetRandomInt(int max)
{
return GetRandomInt(0, max);
}
/// <summary>
/// 產生 0 ~ (int.MaxValue - 1) 的亂數
/// </summary>
/// <returns></returns>
public static int GetRandomInt()
{
return GetRandomInt(int.MaxValue);
}