From 2469b8c88f4a722bfd7930cc8983b40c9c582d97 Mon Sep 17 00:00:00 2001 From: nishi_74322014 Date: Sun, 16 Aug 2026 02:16:49 +0900 Subject: [PATCH 01/13] =?UTF-8?q?=E6=BC=8F=E3=82=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index b22623b2d..d208ad5cf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -144,12 +144,12 @@ gh auth switch --user OsscJpDevInfra # 異なる場合は切り替え | 内容 | 読む文書 | |---|---| | **コーディング規約(全領域共通)** | [`CODING.md`](root/programs/CODING.md) | -| **設定ファイルの扱い(全領域共通)** | [`Configuration.md`](root/programs/Configuration.md) | +| **設定ファイルの扱い(全領域共通)** | [`CONFIGURATION.md`](root/programs/CONFIGURATION.md) | | `root/programs/CS/Frameworks/` の分析 | [`Frameworks/ANALYSIS.md`](root/programs/CS/Frameworks/ANALYSIS.md) | | `root/programs/CS/Samples/` の分析 | [`Samples/ANALYSIS.md`](root/programs/CS/Samples/ANALYSIS.md) | | `root/programs/CS/Samples4NetCore/` の分析 | [`Samples4NetCore/ANALYSIS.md`](root/programs/CS/Samples4NetCore/ANALYSIS.md) | -**設定ファイルに「仕組み」を書き足したくなったら、[`Configuration.md`](root/programs/Configuration.md) +**設定ファイルに「仕組み」を書き足したくなったら、[`CONFIGURATION.md`](root/programs/CONFIGURATION.md) に書く。** 設定ファイルは 86 個あり、一部にだけ詳しい説明があると、 **書かれていないファイルを「該当しない」と誤読させる。** 値の隣に書くのは「そのキーが何か」までにする(分担は同書 0 節)。 From ddc86b316f563e5f27f5dedf2c2cd61d3c2c26c1 Mon Sep 17 00:00:00 2001 From: nishi_74322014 Date: Sun, 16 Aug 2026 04:59:00 +0900 Subject: [PATCH 02/13] fixed #549 --- root/programs/CONFIGURATION.md | 114 +++++++++++++++++- .../MVC_Sample/MVC_Sample/Web.config | 109 +++-------------- .../WebForms_Sample/Web.config | 16 +++ 3 files changed, 141 insertions(+), 98 deletions(-) diff --git a/root/programs/CONFIGURATION.md b/root/programs/CONFIGURATION.md index 8a260b033..bc7f51fd8 100644 --- a/root/programs/CONFIGURATION.md +++ b/root/programs/CONFIGURATION.md @@ -240,10 +240,25 @@ csproj の `CopyToOutputDirectory` で出力フォルダへ配る前提なので 対処は 2 通りある。 -| 方針 | 手段(net10.0) | 手段(net48) | 実測 | -|---|---|---|---| -| **検知**(実態を知らせる) | `UseForwardedHeaders` | IIS の URL Rewrite で `HTTPS` を立てる | 4 件中 **3 件**に `secure` | -| **宣言**(そう決め打つ) | `CookieSecurePolicy=always` | `forms` の `requireSSL="true"` | 4 件中 **4 件** | +| 方針 | 手段(net10.0) | 手段(net48) | +|---|---|---| +| **検知**(実態を知らせる) | `UseForwardedHeaders` | IIS の URL Rewrite で `HTTPS` を立てる | +| **宣言**(そう決め打つ) | `CookieSecurePolicy=always` | `forms` の `requireSSL="true"` | + +**どちらも実測してある**(`X-Forwarded-Proto: https` を付けた要求で `Set-Cookie` を見る)。 + +| | 検知 | 宣言 | +|---|---|---| +| net10.0 | 4 件中 **3 件** | 4 件中 **4 件** | +| net48 | 6 件中 **2 件**(=フレームワークが立てる `SessionTimeOut` の生成・削除の両方) | — | + +net10.0 の検知が 3 件止まりなのは、**削除用 Cookie が +`CookieExtensions.Delete(key)`(オプション無し)を通る**ため。 +net48 側は削除も `newCookie.Secure` を明示しているので、両方に付く。 + +> **net48 では `allowedServerVariables` への登録も要る。** +> `Web.config` からは設定できず(`overrideModeDefault="Deny"`)、 +> `applicationHost.config` に書く。**忘れると要求ごとに HTTP 500.50 になる。** **宣言の方が依存が少なく確実。** `CookiePolicy` はすべての `Set-Cookie` を後段で 上書きするため、個々の箇所が何を判断しているかに依存しない。 @@ -289,6 +304,97 @@ Antiforgery の Cookie が返らず**ログインの POST が 400** になる( --- +### net48 で「検知」する — IIS の URL Rewrite + +**`Request.IsSecureConnection` はコードから変えられない**(読み取り専用)。 +IIS 側で `HTTPS` サーバ変数を立てる。 + +**MVC でも Web Forms でも同じ**である。設定するのは IIS であって、アプリの実装ではない。 + +#### ① `Web.config` に受信規則を書く + +```xml + + + + + + + + + + + + + + + + +``` + +`action type="None"` は「書き換えも転送もしない」。**サーバ変数を立てるためだけの規則**である。 + +#### ② `applicationHost.config` に `HTTPS` を登録する + +**これを忘れると、すべての要求が HTTP 500.50 になる。** + +``` +HTTP Error 500.50 - URL Rewrite Module Error. +The server variable "HTTPS" is not allowed to be set. +Add the server variable name to the allowed server variable list. +``` + +```xml + + + + + +``` + +**`Web.config` からは設定できない。** `allowedServerVariables` は +`overrideModeDefault="Deny"` で、`applicationHost.config` にしか書けない。 +アプリが勝手にサーバ変数を書き換えられないための関門である。 + +#### 実測(IIS Express、`Samples/WebApp_sample/MVC_Sample`) + +| 送ったヘッダ | `secure` が付いた Cookie | +|---|---| +| `X-Forwarded-Proto: https` | **6 件中 2 件**(`SessionTimeOut` の生成・削除の両方) | +| (ヘッダ無し) | 0 件 | +| `X-Forwarded-Proto: http` | 0 件(条件の `^https$` が弾く) | + +`SessionTimeOut` は `FxCmnFunction` が立てる Cookie なので、 +`IsSecureConnection` が true になったことの直接の確認になる。 + +> **ARR は要らない。** ARR は IIS 自身を**リバース プロキシにする**機能で、 +> ここで要るのは URL Rewrite だけ。前段が既にある構成なら ARR は無関係。 + +> **IIS Express で試すときの注意。** +> `/path:` 起動は `%ProgramFiles%\IIS Express\AppServer\applicationhost.config` を読む +> (`%USERPROFILE%\Documents\IISExpress\config\...` ではない)。 +> `/config:` は `/path:` と併用できず、`/site:` が要る。 + +### net48 で鍵を揃える — `machineKey` + +**Web サーバを複数台にするなら要る。** セッションを StateServer や SQLServer へ +外出ししても、それだけでは足りない。 + +**認証 Cookie(`forms`)と ViewState は `machineKey` で保護されている。** +指定しないと**サーバごとに別の鍵が自動生成される**ため、台数を増やした途端、 +片方が発行したものをもう片方が復号できず、 +ログインし直しや「ビューステートの検証に失敗しました」になる。 + +```xml + +``` + +**ViewState を使う Web Forms では、より当たりやすい。** +netcore 側の対応物は DataProtection(10 節)。 + +--- + ## 9. 秘密の扱い サンプルは**パスワードを直書きしている**(すぐ動かせることを優先しているため)。 diff --git a/root/programs/CS/Samples/WebApp_sample/MVC_Sample/MVC_Sample/Web.config b/root/programs/CS/Samples/WebApp_sample/MVC_Sample/MVC_Sample/Web.config index 618f1e5d5..86a89e348 100644 --- a/root/programs/CS/Samples/WebApp_sample/MVC_Sample/MVC_Sample/Web.config +++ b/root/programs/CS/Samples/WebApp_sample/MVC_Sample/MVC_Sample/Web.config @@ -50,112 +50,33 @@ - - - - - - + + + + - + + + + "f53469c17c5a432f86ce563b7805ab89", + "b6b393fe861b430eb4ee061006826b03", + "f374a155909d486a9234693c34e94479" + ]'/> diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/packages.config b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/packages.config index d3678d387..c788277ba 100644 --- a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/packages.config +++ b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/packages.config @@ -1,18 +1,15 @@  - + - - - - - + + @@ -46,7 +43,7 @@ - + @@ -66,5 +63,5 @@ - + \ No newline at end of file diff --git a/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWPF_sample/WSClientWPF_sample_all.sln b/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWPF_sample/WSClientWPF_sample_all.sln index c069ce9fa..d68e44a7a 100644 --- a/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWPF_sample/WSClientWPF_sample_all.sln +++ b/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWPF_sample/WSClientWPF_sample_all.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 18.1.11312.151 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WSClientWPF_sample", "WSClientWPF_sample.vbproj", "{5B5899DA-98C9-47B7-8832-A21768D788B0}" EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ASPNETWebService", "..\..\..\..\Frameworks\Infrastructure\ServiceInterface\ASPNETWebService\ASPNETWebService\ASPNETWebService.vbproj", "{CD8E53D2-B177-494B-AE08-1CEEF98E43D7}" +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ASPNETWebService", "..\..\..\..\Frameworks\Infrastructure\ServiceInterface\ASPNETWebService\ASPNETWebService.vbproj", "{CD8E53D2-B177-494B-AE08-1CEEF98E43D7}" EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WCFService", "..\..\..\..\Frameworks\Infrastructure\ServiceInterface\WCFService\WCFService.vbproj", "{48114116-045D-4BB9-93FD-61306697F589}" EndProject diff --git a/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWin_sample/WSClientWin_sample_all.sln b/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWin_sample/WSClientWin_sample_all.sln index ace5eabd9..257704edb 100644 --- a/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWin_sample/WSClientWin_sample_all.sln +++ b/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWin_sample/WSClientWin_sample_all.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 18.1.11312.151 d18.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WSClientWin_sample", "WSClientWin_sample.vbproj", "{FBA01A43-1A3F-4C92-ABD1-59C51005A084}" EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ASPNETWebService", "..\..\..\..\Frameworks\Infrastructure\ServiceInterface\ASPNETWebService\ASPNETWebService\ASPNETWebService.vbproj", "{CD8E53D2-B177-494B-AE08-1CEEF98E43D7}" +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ASPNETWebService", "..\..\..\..\Frameworks\Infrastructure\ServiceInterface\ASPNETWebService\ASPNETWebService.vbproj", "{CD8E53D2-B177-494B-AE08-1CEEF98E43D7}" EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WCFService", "..\..\..\..\Frameworks\Infrastructure\ServiceInterface\WCFService\WCFService.vbproj", "{48114116-045D-4BB9-93FD-61306697F589}" EndProject From 76e3daad1f38691dcb8e68df2fb00c9e574bf62f Mon Sep 17 00:00:00 2001 From: nishi_74322014 Date: Mon, 17 Aug 2026 14:36:34 +0900 Subject: [PATCH 13/13] fixed #495 --- root/programs/CONFIGURATION.md | 41 ++++-------- root/programs/CompareConfig.ps1 | 25 +++----- .../ASPNETWebService/ASPNETWebService.vbproj | 17 ++--- .../App_Start/BundleConfig.vb | 43 +++++++++++++ .../ASPNETWebService/App_Start/RouteConfig.vb | 50 +++++++++++++++ .../App_Start/WebApiConfig.vb | 27 ++------ .../ASPNETWebService/Global.asax | 1 + .../ASPNETWebService/Global.asax.vb | 50 +++++++++++++++ .../ASPNETWebService/Startup.vb | 63 ------------------- .../ASPNETWebService/packages.config | 3 - .../WSClientWin_sample.vbproj | 16 +++-- .../WSClientWin_sample_all.sln | 22 ++++++- 12 files changed, 209 insertions(+), 149 deletions(-) create mode 100644 root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/BundleConfig.vb create mode 100644 root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/RouteConfig.vb create mode 100644 root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Global.asax create mode 100644 root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Global.asax.vb delete mode 100644 root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Startup.vb diff --git a/root/programs/CONFIGURATION.md b/root/programs/CONFIGURATION.md index b2f35b34c..b00222b20 100644 --- a/root/programs/CONFIGURATION.md +++ b/root/programs/CONFIGURATION.md @@ -448,13 +448,10 @@ dotnet dev-certs https --format Pem -ep ./https/aspnetapp.pem -np | 完全一致 | **8** | | 差分あり | **17** | -> **その後 30 組になった。**(#558) -> `ASPNETWebService` は **VB 側のディレクトリが 1 段深く、対応づけに乗っていなかった。** -> `Web.config` も `app.config` も `packages.config` も、**一度も突き合わされていない。** -> VB の構造を CS に揃えて解消した(現在 : 同一 15 / 差分 15 / **想定外 0**)。 -> +> **組数は必ず見ること。** +> 対応づけは「CS からの相対パスを VB に当てる」方式なので、 +> **階層が一致しないプロジェクトは 1 組も対象に入らない。** > **「差分 0 件」と「対象に入っていない」は、出力の上では区別がつかない。** -> 組数が減っていないかを見ること。 差分の種類は次のとおり(1 組が複数に該当することがある)。 @@ -462,7 +459,7 @@ dotnet dev-certs https --format Pem -ep ./https/aspnetapp.pem -np |---|---|---| | `startup` / `supportedRuntime`(**VB のみ**) | 10 | **違ってよい**(VS が VB プロジェクトに自動で入れる) | | `runtime/assemblyBinding` の `bindingRedirect` | 8 | **違ってよい**(NuGet が生成。参照するパッケージの版で変わる) | -| `packages.config` の構成 | 2 | **解消済み**(#554 / #558。下記) | +| `packages.config` の構成 | 2 | **揃える**(下記) | | `ClientSettingsProvider.ServiceUri`(VB のみ) | 1 | **違ってよい**(VS のテンプレート由来) | | `SqlTextFilePath` の値 | 1 | **違わないといけない**(下記) | | `compilation/assemblies`(VB のみ) | 1 | **違ってよい**(VB は明示参照が要ることがある) | @@ -491,28 +488,12 @@ VB : > `SqlTextFilePath` は「埋め込みリソースなら名前空間、通常のファイルならフォルダのパス」 > という二役を持つ(`MyBaseDao.SetSqlByFile2`)。5 節・7-3 節も参照。 -### **違ってよい**もの — 起動の仕組み(#558) - -`Frameworks/Infrastructure/ServiceInterface/ASPNETWebService` - -| | 起動 | `packages.config` | -|---|---|---| -| CS | `Global.asax` の `Application_Start` | OWIN は入らない | -| **VB** | **`Startup.vb` の ``** | `Owin` / `Microsoft.Owin` / `Microsoft.Owin.Host.SystemWeb` | - -**揃えると VB が起動しなくなる。** 実装方式そのものが違うので、この 3 件は差のままにする。 - -### `packages.config` も突き合わせの対象である(#558) +### `packages.config` も突き合わせの対象である 拡張子が `.config` なので元から対象に入っている。**`$allowed` には入れていない。** -**パッケージ構成のずれは、ビルドが通ってしまうため他に気付く手段が無い。** -実際に `ASPNETWebService` で次が見つかった。 - -| 見つかったもの | 内容 | -|---|---| -| **陳腐化した宣言** 4 件 | `packages.config` にしか出てこない(VB の `FriendlyUrls.Core` / `.ja` / `Optimization.WebForms`、CS の `Modernizr`)。VB に `.aspx` は無く、CS に `Scripts` フォルダも無い | -| **`targetFramework` の残留** 5 件 | プロジェクトは `v4.8` なのに、VB 側の宣言が `net46` のまま。`net46` 時代に入れたきり再インストールされていない | +見るのは、**陳腐化した宣言**(`packages.config` にしか出てこないパッケージ)と +**`targetFramework` の残留**(プロジェクトの `TargetFrameworkVersion` と食い違う宣言)である。 **どちらもビルドは通る。** だから検査でしか見つからない。 @@ -543,8 +524,7 @@ cd root\programs **`-Check` は「差分の有無」ではなく「想定外の差分の有無」を見る。** 上の表で「違ってよい」とした種類(`startup` / `runtime` / `compilation/assemblies` / -`SqlTextFilePath` / `ClientSettingsProvider.*` / **OWIN の 3 パッケージ**)は、 -当てはまれば想定内として扱う。 +`SqlTextFilePath` / `ClientSettingsProvider.*`)は、当てはまれば想定内として扱う。 ``` ================ 判定 ================ @@ -557,6 +537,11 @@ cd root\programs **許容する種類を増やすときは、なぜ違ってよいのかをこの節にも書くこと。** スクリプトの `$allowed` だけに足すと、**理由が残らない。** +**そして、足す前に「なぜ違うのか」を履歴で確かめること。** +**「差がある」ことと「違ってよい」ことは別である。** +理由が「片側だけ作業が済んでいない」なら、**許容ではなく、作業を終わらせるのが答え**になる。 +`$allowed` に入れてしまうと、**やり残しが「仕様」として固定される。** + `compilation/assemblies` の欠落と接続文字列の `;` は、この方法で見つけた。 > **CI は代わりにならない。** diff --git a/root/programs/CompareConfig.ps1 b/root/programs/CompareConfig.ps1 index b5e90b40c..60c7a5c39 100644 --- a/root/programs/CompareConfig.ps1 +++ b/root/programs/CompareConfig.ps1 @@ -23,17 +23,19 @@ **同じにすると壊れる差分**もある(埋め込みリソース名。CS はフォルダ名を含み、 VB は含まない)。判断の材料は [`CONFIGURATION.md`](CONFIGURATION.md) 11 節。 - **`packages.config` は対象である。**(#558 で説明を訂正) + **`packages.config` は対象である。** 拡張子が `.config` なので元から突き合わせており、`$allowed` にも入れていない。 パッケージ構成のずれ(片側だけ更新した、陳腐化した宣言が残っている)は、 **ビルドが通ってしまうため、これ以外に気付く手段が無い。** - <対応づけは相対パスで、見つからなければ探す> + <対応づけは相対パスだけ> - CS からの相対パスを VB に当てるのが基本だが、**階層が一致しないことがある。** - `ASPNETWebService` は VB 側が 1 段深く、**5 ファイルとも一度も - 突き合わされていなかった**(#558 で構造を CS に揃えて解消)。 - 同じことが起きていないかは、対象の組数で分かる。 + **CS からの相対パスを VB にそのまま当てる。探しには行かない。** + (ファイル名の大文字小文字だけは吸収する) + + **階層が一致しないプロジェクトは、1 組も対象に入らない。** + そして**何も出力されない**ので、一覧を見ても気付けない。 + **組数で確かめること。** .PARAMETER Detail 差分の内訳(どの要素・属性が増減したか)を表示する。 @@ -56,8 +58,6 @@ appSettings の SqlTextFilePath **同じにすると壊れる**(言語で  埋め込みリソース名の規則が違う) appSettings の ClientSettingsProvider.* VS のテンプレート由来 - packages の Owin / Microsoft.Owin.* **起動の仕組みが違う**(VB は OWIN -                      Startup、CS は Global.asax) **この一覧は「今そうなっている」ではなく「そうであってよい」を表す。** 増やすときは、なぜ違ってよいのかを CONFIGURATION.md 11 節にも書くこと。 @@ -78,7 +78,8 @@ ---------- ---------------- ------------------------------------------------- 2026/08/16 玄人 幸道 新規作成(#553) 2026/08/16 玄人 幸道 -Check を追加(#553) - 2026/08/17 玄人 幸道 OWIN を $allowed に追加、説明を訂正(#558) + 2026/08/17 玄人 幸道 説明を訂正(#558)packages.config は対象である。 +                 対応づけは相対パスのみで、探しには行かない。 -Check を付けない限り、終了コードは常に 0。 **差分があること自体は異常ではない**ため、既定は一覧として使う。 @@ -101,12 +102,6 @@ $allowed = @( '^/configuration/system\.web/compilation/assemblies' '^/configuration/appSettings/add \[key=SqlTextFilePath' '^/configuration/appSettings/add \[key=ClientSettingsProvider\.' - - # **ASPNETWebService は起動の仕組みが CS と VB で違う。**(#558) - # VB は Startup.vb の OWIN 方式、CS は Global.asax 方式。 - # **揃えると VB が起動しなくなる**ため、OWIN の 3 パッケージは差のままにする。 - '^/packages/package \[id=Owin;' - '^/packages/package \[id=Microsoft\.Owin(\.|;)' ) $ErrorActionPreference = "Continue" diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/ASPNETWebService.vbproj b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/ASPNETWebService.vbproj index f5e605058..60a372dba 100644 --- a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/ASPNETWebService.vbproj +++ b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/ASPNETWebService.vbproj @@ -110,12 +110,6 @@ packages\Microsoft.IdentityModel.Tokens.8.12.0\lib\net472\Microsoft.IdentityModel.Tokens.dll - - packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll - - - packages\Microsoft.Owin.Host.SystemWeb.4.2.2\lib\net45\Microsoft.Owin.Host.SystemWeb.dll - packages\Microsoft.Web.Infrastructure.2.0.0\lib\net40\Microsoft.Web.Infrastructure.dll @@ -134,10 +128,6 @@ ..\..\Build\OpenTouryo.Public.dll - - packages\Owin.1.0\lib\net40\Owin.dll - True - packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll @@ -291,6 +281,7 @@ + Designer @@ -303,9 +294,14 @@ + + + + Global.asax + True @@ -326,7 +322,6 @@ Settings.settings True - diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/BundleConfig.vb b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/BundleConfig.vb new file mode 100644 index 000000000..803632b07 --- /dev/null +++ b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/BundleConfig.vb @@ -0,0 +1,43 @@ +#Region "Apache License" +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. +' +#End Region + +'********************************************************************************** +'* クラス名 :BundleConfig +'* クラス日本語名 :バンドル&ミニフィケーションに関する指定 +'* +'* 作成者 :玄人 幸道 +'* 更新履歴 : +'* +'* 日時 更新者 内容 +'* ---------- ---------------- ------------------------------------------------- +'* 2026/08/17 玄人 幸道 新規作成(#558)C#版に合わせて追加。 +'********************************************************************************** + +Imports System.Web.Optimization + +Namespace ASPNETWebService + ''' バンドル&ミニフィケーションに関する指定 + Public Class BundleConfig + ''' バンドルの登録 + ''' BundleCollection + ''' + ''' バンドルの詳細については、https://go.microsoft.com/fwlink/?LinkId=301862 を参照。 + ''' このプロジェクトは WebAPI のみで画面を持たないため、登録するものは無い。 + ''' + Public Shared Sub RegisterBundles(bundles As BundleCollection) + End Sub + End Class +End Namespace diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/RouteConfig.vb b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/RouteConfig.vb new file mode 100644 index 000000000..d33186b72 --- /dev/null +++ b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/RouteConfig.vb @@ -0,0 +1,50 @@ +#Region "Apache License" +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. +' +#End Region + +'********************************************************************************** +'* クラス名 :RouteConfig +'* クラス日本語名 :ルート定義に関する指定(MVC用) +'* +'* 作成者 :玄人 幸道 +'* 更新履歴 : +'* +'* 日時 更新者 内容 +'* ---------- ---------------- ------------------------------------------------- +'* 2026/08/17 玄人 幸道 新規作成(#558)C#版に合わせて追加。 +'********************************************************************************** + +Imports System.Web.Mvc +Imports System.Web.Routing + +Namespace ASPNETWebService + ''' ルート定義に関する指定(MVC用) + Public Class RouteConfig + ''' ルートの登録 + ''' RouteCollection + Public Shared Sub RegisterRoutes(routes As RouteCollection) + routes.IgnoreRoute("{resource}.axd/{*pathInfo}") + + routes.MapRoute( + name:="Default", + url:="{controller}/{action}/{id}", + defaults:=New With { + .controller = "Home", + .action = "Index", + Key .id = UrlParameter.[Optional] + }) + End Sub + End Class +End Namespace diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/WebApiConfig.vb b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/WebApiConfig.vb index c3ea84e9b..d42bf9ee3 100644 --- a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/WebApiConfig.vb +++ b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/App_Start/WebApiConfig.vb @@ -15,42 +15,25 @@ '* 日時 更新者 内容 '* ---------- ---------------- ------------------------------------------------- '* 20xx/xx/xx XX XX XXXX +'* 2026/08/17 玄人 幸道 C#版に合わせた(#558)。C#版は #495 の +'* テンプレート差し替えで、この形になっている。 '********************************************************************************** Imports System.Web.Http -'using Microsoft.Owin.Security.OAuth; - -Imports Newtonsoft.Json.Serialization Namespace ASPNETWebService Public NotInheritable Class WebApiConfig Private Sub New() End Sub Public Shared Sub Register(config As HttpConfiguration) - '/ Web API configuration and services - '/ 「Bearer Token」認証のみを使用するように、Web API を設定。 - 'config.SuppressDefaultHostAuthentication(); - 'config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType)); - - ' JSON データにはDefaultを使用 (JSON.NET) - config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = New DefaultContractResolver() - - ' CORS (Cross-Origin Resource Sharing)の有効化 - ' 別ドメイン上で動作する Web アプリからアクセス可能に設定。 - config.EnableCors() + ' Web API の設定およびサービス - ' Web API routes を設定する。 - - ' Attribute Routing + ' Web API ルート config.MapHttpAttributeRoutes() - ' MapHttpRoute - config.Routes.MapHttpRoute(name:="DefaultApi", routeTemplate:="api/{controller}/{action}/{id}", defaults:=New With { + config.Routes.MapHttpRoute(name:="DefaultApi", routeTemplate:="api/{controller}/{id}", defaults:=New With { Key .id = RouteParameter.[Optional] }) - - '/ トレース機能を有効化します。 - 'TraceConfig.Register(config); End Sub End Class End Namespace diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Global.asax b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Global.asax new file mode 100644 index 000000000..39ffbb481 --- /dev/null +++ b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.vb" Inherits="ASPNETWebService.WebApiApplication" Language="VB" %> diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Global.asax.vb b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Global.asax.vb new file mode 100644 index 000000000..813a65efa --- /dev/null +++ b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Global.asax.vb @@ -0,0 +1,50 @@ +#Region "Apache License" +' +' Licensed under the Apache License, Version 2.0 (the "License"); +' you may not use this file except in compliance with the License. +' You may obtain a copy of the License at +' +' http://www.apache.org/licenses/LICENSE-2.0 +' +' Unless required by applicable law or agreed to in writing, software +' distributed under the License is distributed on an "AS IS" BASIS, +' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +' See the License for the specific language governing permissions and +' limitations under the License. +' +#End Region + +'********************************************************************************** +'* クラス名 :WebApiApplication +'* クラス日本語名 :Global.asaxのコード ビハインド +'* +'* 作成者 :玄人 幸道 +'* 更新履歴 : +'* +'* 日時 更新者 内容 +'* ---------- ---------------- ------------------------------------------------- +'* 2026/08/17 玄人 幸道 新規作成(#558) +'* Startup.vb(OWIN)から Global.asax 方式へ載せ替え。 +'* C#版(#495 でテンプレート差し替え済み)に合わせた。 +'********************************************************************************** + +Imports System.Web.Http +Imports System.Web.Mvc +Imports System.Web.Optimization +Imports System.Web.Routing + +Namespace ASPNETWebService + ''' Global.asaxのコード ビハインド + Public Class WebApiApplication + Inherits System.Web.HttpApplication + + ''' アプリケーションの開始に関するイベント + Protected Sub Application_Start() + AreaRegistration.RegisterAllAreas() + GlobalConfiguration.Configure(AddressOf WebApiConfig.Register) + FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters) + RouteConfig.RegisterRoutes(RouteTable.Routes) + BundleConfig.RegisterBundles(BundleTable.Bundles) + End Sub + End Class +End Namespace diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Startup.vb b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Startup.vb deleted file mode 100644 index b60359fc5..000000000 --- a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/Startup.vb +++ /dev/null @@ -1,63 +0,0 @@ -'********************************************************************************** -'* テンプレート -'********************************************************************************** - -' サンプル中のテンプレートなので、必要に応じて使用して下さい。 - -'********************************************************************************** -'* クラス名 :OwinStartup -'* クラス日本語名 :OwinStartup -'* -'* 作成日時 :- -'* 作成者 :- -'* 更新履歴 :- -'* -'* 日時 更新者 内容 -'* ---------- ---------------- ------------------------------------------------- -'* 20xx/xx/xx XX XX XXXX -'********************************************************************************** - -Imports System.Web.Mvc -Imports System.Web.Http -Imports System.Net.Http - -Imports Owin -Imports Microsoft.Owin - -Imports Touryo.Infrastructure.Framework.Authentication - - - -Namespace ASPNETWebService - Public Class Startup - ''' Configuration - ''' - Public Sub Configuration(app As IAppBuilder) - ' アプリケーションの設定方法の詳細については、http://go.microsoft.com/fwlink/?LinkID=316888 を参照してください - - ' アプリケーションのスタートアップで実行するコードです - - ' - AreaRegistration.RegisterAllAreas() - - ' - WebApiConfig.Register(GlobalConfiguration.Configuration) - - ' グローバルフィルタの登録 - FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters) - - '' URLルーティングの登録 - 'RouteConfig.RegisterRoutes(RouteTable.Routes) - - '' バンドル&ミニフィケーションの登録 - 'BundleConfig.RegisterBundles(BundleTable.Bundles) - - '/ 認証に関するOWINミドルウェアの設定を行う。 - 'StartupAuth.Configure(app); - OAuth2AndOIDCClient.HttpClient = New HttpClient() ' JwkSet取得用 - - GlobalConfiguration.Configuration.EnsureInitialized() - 'GlobalConfiguration.Configuration.Initializer(GlobalConfiguration.Configuration) ?? - End Sub - End Class -End Namespace diff --git a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/packages.config b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/packages.config index c788277ba..2e0bfa983 100644 --- a/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/packages.config +++ b/root/programs/VB/Frameworks/Infrastructure/ServiceInterface/ASPNETWebService/packages.config @@ -38,12 +38,9 @@ - - - diff --git a/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWin_sample/WSClientWin_sample.vbproj b/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWin_sample/WSClientWin_sample.vbproj index e8032f00f..2f7e1f004 100644 --- a/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWin_sample/WSClientWin_sample.vbproj +++ b/root/programs/VB/Samples/WS_sample/WSClient_sample/WSClientWin_sample/WSClientWin_sample.vbproj @@ -81,12 +81,6 @@ - - ..\..\Build\WSIFType_sample.dll - - - ..\..\Build\WSServer_sample.dll - @@ -178,6 +172,16 @@ 13.0.3 + + + {f6e2bd99-672a-4f69-82e3-eee5d9b639df} + WSIFType_sample + + + {15f78db3-7ab0-4adf-adca-48afbd54c31e} + WSServer_sample + +