2024年7月23日 星期二

Asp.net 404.15 - Not found

連結字串長度問題
修改web.confiog
<system.web>
  <httpRuntime maxQueryStringLength="102400" maxUrlLength="102400" />
</system.web>
<system.webServer>
 <security>
  <requestFiltering>
   <requestLimits maxUrl="102400" maxQueryString="102400" />
  </requestFiltering>
 </security>
</system.webServer>

2024年7月8日 星期一

jQueryUI datepicker改變字體大小或CSS

  $('.datepicker').datepicker({
      beforeShow: function () {
          setTimeout(function () {            
              $('.ui-datepicker').css('font-size', '16px');
          }, 0);
      }
  });

2024年5月31日 星期五

Google AdSense 廣告申請未過原因,讓AI來翻譯吧

負責團隊已審查完畢,但很抱歉,您的網站目前無法放送廣告。
您的網站有些問題,必須先修正才能開始放送廣告。
英文原文如下
1
00:00:05,872 --> 00:00:07,807
Hi welcome to the Google Ads channel. 

2
00:00:08,108 --> 00:00:12,12
I'm andreas, and today I will be taking 
you through the best practices to help 

3
00:00:12,12 --> 00:00:13,279
you get your side approved.

4
00:00:14,114 --> 00:00:17,384
I will be giving you three 
recommendations to increase the chances 

5
00:00:17,617 --> 00:00:20,153
of getting your sites approval status 
to ready,

6
00:00:20,920 --> 00:00:22,722
before diving into the best practices.

7
00:00:23,56 --> 00:00:24,157
Let me introduce them to you.

8
00:00:24,991 --> 00:00:28,495
The first best practice is to make sure 
your site has the correct adcoat.

9
00:00:29,295 --> 00:00:29,763
Next,

10
00:00:30,96 --> 00:00:32,198
we've a second practice on having the 
site available. 

11
00:00:32,999 --> 00:00:36,436
Last but not least, we will talk about 
our program policies to ensure the site 

12
00:00:36,569 --> 00:00:37,404
is policy compliant. 

13
00:00:38,38 --> 00:00:39,372
So let's get started.

14
00:00:39,773 --> 00:00:43,43
The first best practice is to make sure 
your code is complete and correct.

15
00:00:43,610 --> 00:00:47,147
After you've generated the ad code, you 
will need to place the ad code into the 

16
00:00:47,147 --> 00:00:48,148
hcml of your site.

17
00:00:48,815 --> 00:00:52,752
You need to place the ad code in the 
head tag or at the top of the body of 

18
00:00:52,752 --> 00:00:53,86
your page. 

19
00:00:53,386 --> 00:00:54,721
Without making any changes,

20
00:00:55,221 --> 00:00:58,658
please make sure you've placed the code 
into the same site you've added in your 

21
00:00:58,758 --> 00:00:59,526
ad sense account.

22
00:00:59,959 --> 00:01:03,296
Alternatively, you can verify your side 
ownership in search console. 

23
00:01:03,697 --> 00:01:03,997
Instead,

24
00:01:04,497 --> 00:01:08,34
if we detect that you verified your 
site in search conso we'll continue 

25
00:01:08,335 --> 00:01:10,503
checking if your site is ready to show 
Ads. 

26
00:01:10,837 --> 00:01:14,74
The second best practice is to make 
sure your site is reachable.

27
00:01:14,841 --> 00:01:18,278
We often review websites which may be 
down or not loading correctly. 

28
00:01:18,978 --> 00:01:21,614
Therefore we are unable to review these 
sites.

29
00:01:22,415 --> 00:01:26,920
Make sure that the url used to sign up 
for the adsense account is correct and 

30
00:01:26,986 --> 00:01:27,554
open running. 

31
00:01:27,721 --> 00:01:28,154
Globally

32
00:01:28,888 --> 00:01:32,592
your site would be unavailable if you 
need a password to access the site. 

33
00:01:33,59 --> 00:01:36,262
If your sites login is password 
protected, consider temporarily 

34
00:01:36,730 --> 00:01:39,532
removing the login screen so that we 
can reach your site.

35
00:01:40,900 --> 00:01:45,638
Also make sure you are not blocking our 
crawler in your robot satx t file. 

36
00:01:45,872 --> 00:01:49,943
To avoid any crawler issues, you can 
see more details on why your site might 

37
00:01:49,943 --> 00:01:51,945
be unreachable by clicking on the help 
center. 

38
00:01:52,112 --> 00:01:53,913
Link that's in the description of this 
video.

39
00:01:54,581 --> 00:01:58,251
The final best practice is to make sure 
your site is policy compliant.

40
00:01:58,818 --> 00:02:01,788
Please review our program policies and 
content policies. 

41
00:02:02,88 --> 00:02:02,722
In particular,

42
00:02:03,390 --> 00:02:07,961
we've observed three main violations by 
our publishers that will highlight next 

43
00:02:08,28 --> 00:02:08,962
to help you avoid them.

44
00:02:09,295 --> 00:02:11,664
The first violation is low value 
content.

45
00:02:12,32 --> 00:02:14,668
Make sure the content is original and 
valuable to your users. 

46
00:02:15,235 --> 00:02:17,704
The second violation is having 
replicated content. 

47
00:02:18,271 --> 00:02:21,875
Ensure that your content is unique and 
it's not repetitive on different pages 

48
00:02:22,8 --> 00:02:25,712
of your site, when the same content is 
found replicated on your pages or on 

49
00:02:25,712 --> 00:02:27,147
other sides, your site will be 
approved. 

50
00:02:27,714 --> 00:02:30,550
The third and the last main violation 
is site navigation.

51
00:02:30,917 --> 00:02:33,319
Users need to be able to easily 
navigate your site. 

52
00:02:33,620 --> 00:02:37,757
This can be achieved by categorizing 
your content using menu bars and so on.

53
00:02:38,91 --> 00:02:41,861
Keep in mind that we may review all 
pages of your site, and not just the 

54
00:02:41,861 --> 00:02:44,164
sign up url where you place the ad code.

55
00:02:44,497 --> 00:02:48,101
That's why it's very important to make 
sure each page has valuable content 

56
00:02:48,568 --> 00:02:50,870
that is not repetitive and is easy to 
navigate.

57
00:02:51,371 --> 00:02:55,542
In addition to these, we advise placing 
ad code on the most popular page of 

58
00:02:55,608 --> 00:02:58,912
your site, which will trigger our 
system into recognizing your ad code 

59
00:02:59,79 --> 00:03:00,814
and speed up the activation process.

60
00:03:01,381 --> 00:03:04,184
Last but not least, keep your site in 
the sites list. 

61
00:03:04,517 --> 00:03:06,886
As removing it might delay the review 
process

62
00:03:07,220 --> 00:03:07,620
to summarize. 

63
00:03:08,121 --> 00:03:10,724
Here are the most important points to 
get your account activated.

64
00:03:11,291 --> 00:03:15,195
One, copy the code exactly as it 
appears in your outsense home page.

65
00:03:15,695 --> 00:03:16,329
Two,

66
00:03:16,496 --> 00:03:17,931
make sure your side is reachable.

67
00:03:18,331 --> 00:03:20,467
And three, review our program policies.

68
00:03:21,1 --> 00:03:24,637
We hope this video helps you better 
understand how you can get your site approved.

69
00:03:25,138 --> 00:03:28,575
To learn more, you can visit the 
adsense help center, an ad sense 

70
00:03:28,742 --> 00:03:31,678
website, vie the links in the 
description of this video.

71
00:03:32,112 --> 00:03:35,715
Last but not least, make sure to 
subscribe to the Google outsense 

72
00:03:36,116 --> 00:03:39,986
channel for more best practices on how 
you can grow your side further.

73
00:03:40,820 --> 00:03:41,621
Thank you for watching. 

74
00:03:41,955 --> 00:03:46,92
And let us know in the comments section 
if you have any suggestions for new videos


讓AI來翻譯吧
1
00:00:05,872 --> 00:00:07,807
嗨,歡迎來到 Google Ads 頻道。

2
00:00:08,108 --> 00:00:12,12
我是 Andreas,今天我會帶你
了解一些最佳做法,幫助你

3
00:00:12,12 --> 00:00:13,279
讓你的網站獲得批准。

4
00:00:14,114 --> 00:00:17,384
我會給你三個
增加網站審核通過機會的建議,

5
00:00:17,617 --> 00:00:20,153
在深入了解最佳做法之前。

6
00:00:20,920 --> 00:00:22,722
讓我先介紹一下這些建議。

7
00:00:23,56 --> 00:00:24,157
第一個最佳做法是確保
你的網站有正確的廣告代碼。

8
00:00:24,991 --> 00:00:28,495
接下來,

9
00:00:29,295 --> 00:00:29,763
我們有第二個做法,就是確保網站可用。

10
00:00:30,96 --> 00:00:32,198
最後但同樣重要的是,我們會談論
我們的計畫政策,以確保網站符合政策。

11
00:00:32,999 --> 00:00:36,436

12
00:00:36,569 --> 00:00:37,404
那麼,我們開始吧。

13
00:00:38,38 --> 00:00:39,372
第一個最佳做法是確保
你的代碼完整且正確。

14
00:00:39,773 --> 00:00:43,43
在你生成廣告代碼後,
需要將廣告代碼放入你網站的 HTML 中。

15
00:00:43,610 --> 00:00:47,147
需要將廣告代碼放在 head 標籤或
頁面的 body 標籤頂部。

16
00:00:47,147 --> 00:00:48,148
不要進行任何更改,

17
00:00:48,815 --> 00:00:52,752
請確保將代碼放入與
你在 Adsense 帳戶中添加的相同網站中。

18
00:00:52,752 --> 00:00:53,86
或者,

19
00:00:53,386 --> 00:00:54,721
你可以在搜尋控制台中驗證你的网站所有權。

20
00:00:55,221 --> 00:00:58,658
如果我們檢測到你在搜尋控制台中
驗證了你的网站,我們將繼續檢查

21
00:00:58,758 --> 00:00:59,526
你的網站是否準備好顯示廣告。

22
00:00:59,959 --> 00:01:03,296
第二個最佳做法是確保
你的網站可訪問。

23
00:01:03,697 --> 00:01:03,997
我們經常審核

24
00:01:04,497 --> 00:01:08,34
無法正常加載或正在宕機的網站。

25
00:01:08,335 --> 00:01:10,503
因此我們無法審核這些網站。

26
00:01:10,837 --> 00:01:14,74
確保用於註冊 Adsense 帳戶的 URL 正確無誤且全球可訪問。

27
00:01:14,841 --> 00:01:18,278
如果你的网站需要密碼才能訪問,
則不可訪問。

28
00:01:18,978 --> 00:01:21,614
如果你的网站登入需要密碼,
請考慮暫時移除登入頁面以便我們訪問。

29
00:01:22,415 --> 00:01:26,920
同時確保沒有在 robots.txt 檔案中
阻止我們的爬蟲。

30
00:01:26,986 --> 00:01:27,554
為了避免任何爬蟲問題,

31
00:01:27,721 --> 00:01:28,154
你可以通過點擊此影片描述中的幫助中心連結,

32
00:01:28,888 --> 00:01:32,592
查看更多關於你的网站為何不可訪問的詳細信息。

33
00:01:33,59 --> 00:01:36,262
最後一個最佳做法是確保
你的網站符合政策。

34
00:01:36,730 --> 00:01:39,532
請審查我們的計畫政策和內容政策。

35
00:01:40,900 --> 00:01:45,638
特別是,

36
00:01:45,872 --> 00:01:49,943
我們觀察到的三個主要違規行為將在接下來的部分突顯顯示,

37
00:01:49,943 --> 00:01:51,945
以幫助你避免它們。

38
00:01:52,112 --> 00:01:53,913
第一個違規行為是低價值內容。

39
00:01:54,581 --> 00:01:58,251
確保內容是原創且對用戶有價值。

40
00:01:58,818 --> 00:02:01,788
第二個違規行為是重複內容。

41
00:02:02,88 --> 00:02:02,722
確保你的內容是唯一的,

42
00:02:03,390 --> 00:02:07,961
而不是在不同頁面上重複出現。

43
00:02:08,28 --> 00:02:08,962
當在你的頁面上或其他網站上發現重複內容時,

44
00:02:09,295 --> 00:02:11,664
你的網站將無法獲得批准。

45
00:02:12,32 --> 00:02:14,668
第三個主要違規行為是網站導航。

46
00:02:15,235 --> 00:02:17,704
用戶需要能夠輕鬆地導航你的网站。

47
00:02:18,271 --> 00:02:21,875
可以通過使用選單欄等方式對內容進行分類來實現這一點。

48
00:02:22,8 --> 00:02:25,712
請記住,我們可能會審核你网站的所有頁面,
而不僅僅是你放置廣告代碼的註冊 URL。

49
00:02:25,712 --> 00:02:27,147
這就是為什麼確保每個頁面都有有價值的內容

50
00:02:27,714 --> 00:02:30,550
且不重複且易於導航是非常重要的。

51
00:02:30,917 --> 00:02:33,319
此外,我們建議將廣告代碼放在

52
00:02:33,620 --> 00:02:37,757
你網站上最受歡迎的頁面上,
這將觸發我們的系統識別你的廣告代碼並加速激活過程。

53
00:02:38,91 --> 00:02:41,861
最後,請確保你的网站保留在网站列表中,

54
00:02:41,861 --> 00:02:44,164
因為刪除它可能會延遲審核過程。

55
00:02:44,497 --> 00:02:48,101
總結一下,

56
00:02:48,568 --> 00:02:50,870
這裡是讓你的帳戶激活的幾個最重要的要點。

57
00:02:51,371 --> 00:02:55,542
一,準確複製廣告代碼到 Adsense 首頁上。

58
00:02:55,608 --> 00:02:58,912
二,確保你的網站可訪問。

59
00:02:59,79 --> 00:03:00,814
三,審查我們的計畫政策。

60
00:03:01,381 --> 00:03:04,184
希望這個影片能幫助你更好地了解如何讓你的網站獲得批准。

61
00:03:04,517 --> 00:03:06,886
想了解更多,你可以訪問
Adsense 幫助中心和 Adsense

62
00:03:07,220 --> 00:03:07,620
網站,通過影片描述中的連結。

63
00:03:08,121 --> 00:03:10,724
最後,請務必訂閱 Google Adsense 頻道,

64
00:03:11,291 --> 00:03:15,195
以獲取更多關於如何進一步發展你的网站的最佳做法。

65
00:03:15,695 --> 00:03:16,329
謝謝觀看。

66
00:03:16,496 --> 00:03:17,931
如果你有任何新影片的建議,
請在評論區告訴我們。

2024年5月30日 星期四

Asp.net MVC Web.config導頁設定

以下筆記一下而已
<?xml version="1.0" encoding="utf-8"?>
<configuration>

<system.webServer>
	<httpProtocol>
		<customHeaders>
			<clear />
			<add name="X-UA-Compatible" value="IE=Edge" />
		</customHeaders>
	</httpProtocol>
	<httpErrors>
		<remove statusCode="502" subStatusCode="-1" />
		<remove statusCode="501" subStatusCode="-1" />
		<remove statusCode="500" subStatusCode="-1" />
		<remove statusCode="406" subStatusCode="-1" />
		<remove statusCode="412" subStatusCode="-1" />
		<remove statusCode="405" subStatusCode="-1" />
		<remove statusCode="404" subStatusCode="-1" />
		<remove statusCode="403" subStatusCode="-1" />
		<remove statusCode="401" subStatusCode="-1" />
		<error statusCode="401" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
		<error statusCode="403" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
		<error statusCode="404" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
		<error statusCode="405" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
		<error statusCode="412" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
		<error statusCode="406" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
		<error statusCode="500" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
		<error statusCode="501" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
		<error statusCode="502" prefixLanguageFilePath="" path="https://easyusingx.blogspot.com/" responseMode="Redirect" />
	</httpErrors>
</system.webServer>
</configuration>

2024年3月1日 星期五

Asp.net MVC Razor Page Url.Action編碼問題

在Razore Page的裡面使用Url.Action
在JS內會產生連結
連結怎麼點都會錯,仔細一看&被編碼了
外面包一層Html.Raw以免被編碼
這樣連結就會正常
參考資料
Url.Action puts an & in my url, how can I solve this?

2024年2月19日 星期一

c# Unix Timestamp轉換

近期專案接觸到很多API
發現目前大多數日期都是數字,查了一下是Unix Timestamp
寫了兩個Function來互轉
時間轉數字
public static double DateToDouble(DateTime? pNow = null)
{
    DateTime mNow = DateTime.Now;
    if (pNow != null && pNow.HasValue)
    {
        mNow = pNow.Value;
    }
    DateTimeOffset t = DateTimeOffset.Parse(mNow.ToString("yyyy-MM-dd HH:mm:ss"));
    return Convert.ToDouble(t.ToUnixTimeSeconds());
}
數字轉時間
  public static DateTime DoubleToDate(double? pDate = 0)
  {
      double d = 0;
      if (pDate != null && pDate.HasValue)
      {
          d = pDate.Value;
      }

      if (d > 9999999999)
          d = d / 1000;

      DateTime StartComputerFirstDay = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
      return StartComputerFirstDay.AddSeconds(d).ToLocalTime();
  }
參考資料
[C#] 時間轉換為Unix TimeStamp
Epoch (computing)
The Current Epoch Unix Timestamp

2024年1月25日 星期四

.Net Core The SSL connection could not be established, see inner exception.

在使用HttpClient時出現錯誤
The SSL connection could not be established, see inner exception.
網路上能找的解法都用上了都沒用
後來猜想是不是TLS支援度問題
所以將程式移至另一台OS較新的Server上就可以了
Server 2012 X > Server 2016 O
參考資料
The SSL connection could not be established, see inner exception.
Windows Server2012 R2不支持TLS1.3

2023年12月4日 星期一

.Net Core Scaffold-DbContext複數化問題及不產生不產生OnConfiguring

早上寫好程式後更新Model卻發生了以下問題
Cannot create a DbSet for 'xxxMinutes' because this type is not included in the model for the context.
後來找了一下xxxMinutes多了一個xxxMinute的Class
原來的
Scaffold-DbContext "Server=192.168.0.1;Database=abc;user id=sa;password=12345678;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models  -Project board.model  -UseDatabaseNames -NoOnConfiguring -Force   
多加一個-NoPluralize停止複數化
多加一個-NoOnConfiguring不產生OnConfiguring
Scaffold-DbContext "Server=192.168.0.1;Database=abc;user id=sa;password=12345678;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models  -Project board.model  -UseDatabaseNames -NoOnConfiguring -NoPluralize -Force   
參考資料
Entity Framework Core tools reference - Package Manager Console in Visual Studio

2023年11月2日 星期四

.Net Core Resolve nullable warnings

.Net6專案常會產生Resolve nullable warnings
關掉的方法找到專案的.csproj(或右鍵編輯專案檔)
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
  </PropertyGroup>
修改
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>disable</Nullable>
  </PropertyGroup>
參考資料
可為 Null 的參考型別
.NET 6学习笔记(4)——解决VS2022中Nullable警告
Resolve nullable warnings

2023年10月31日 星期二

.Net Core 如何新增Area區域

1.專案右鍵 > 加入 > 新增Scaffold項目
2.MVC區域 > 加入
3.在Program.cs
 app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");
加入
 app.MapControllerRoute(
    name: "MyArea",
    pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");
4.在Controller加入Area tag
參考資料
ASP.NET Core 中的區域

.Net Core 發佈後多了許多語言檔資料夾

.net發佈網站後可能會多了許多沒用的語言檔資料夾
找到專案的.csproj(或右鍵編輯專案檔)
 <PropertyGroup>
   <TargetFramework>net6.0</TargetFramework>
 </PropertyGroup>
修改
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
	<SatelliteResourceLanguages>en-US;zh-TW</SatelliteResourceLanguages>
  </PropertyGroup>
乾淨多了
參考資料
【笨問題】防止 .NET 編譯產生不需要的多語系資源檔
ASP.Net Core exclude published language directories other than english

2023年10月27日 星期五

c# 變更ClickOnce產生出的setup.exe的icon

使用ClickOnce會自動更新,所以有時給user時會直接給setup.exe
但icon的話就有可能跟別的重複,比較不好分辨
以下方法可修改icon
1.開啟Visual Studio
2.檔案 > 開啟 > 檔案 > 選擇setup.exe
3.icon > 加入資源
4.匯入 > 選擇icon
5.確保匯入後的編號在前面即可
PS.windows有時候不會即時變更顯示,須重開機
參考資料
【转】vs2012 打包安装更改 setup.exe的图标
How to change Setup.exe icon when publishing through clickonce

2023年10月20日 星期五

.Net Core AnonymousID

購物車常使用的技巧Request.AnonymousID
在.Net Core因為沒參考System.Web
可改用ReturnTrue.AspNetCore.Identity.Anonymous
Startup.cs加入
app.UseAnonymousId();
取得方式
  IAnonymousIdFeature feature = HttpContext.Features.Get<IAnonymousIdFeature>();
  string anonymousId = string.Empty;
  if (feature != null)
  {
      anonymousId = feature.AnonymousId;
  }
參考資料
Git Hub AnonymousId
ReturnTrue.AspNetCore.Identity.Anonymous