Skip to content

Instantly share code, notes, and snippets.

@daisukenishino2
Last active April 23, 2019 09:31
Show Gist options
  • Save daisukenishino2/589901e08e3074ad9eb669f6d0b0d26a to your computer and use it in GitHub Desktop.
Save daisukenishino2/589901e08e3074ad9eb669f6d0b0d26a to your computer and use it in GitHub Desktop.
Open棟梁(MVC版)の *.config ファイル内の設定の説明 https://github.com/OpenTouryoProject/OpenTouryoDocuments/blob/master/documents/1_User_Guide/ja-JP/1b_config_parameter_list.xls に記載がないモノ。
<?xml version="1.0" encoding="utf-8"?>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<!-- フレームワークの使用するパラメータ - start -->
<!-- 基盤画面パス -->
<add key="FxErrorScreenPath" value="/Error/Index" />
<!--リソース ファイルの場合-->
<add key="FxXMLMSGDefinition" value="C:\root\files\resource\Xml\MSGDefinition.xml" />
<add key="FxXMLSPDefinition" value="C:\root\files\resource\Xml\SPDefinition.xml" />
<!--埋め込まれたリソースの場合-->
<!--add key="FxXMLMSGDefinition" value="_2CSClientWin_sample.MSGDefinition.xml"/-->
<!--add key="FxXMLSPDefinition" value="_2CSClientWin_sample.SPDefinition.xml"/-->
<!-- フレームワークの使用するパラメータ - end -->
<!-- 共通部品の使用するパラメータ - start -->
<!-- Log4Netのコンフィグファイルへのパス -->
<!-- リソース ファイルの場合 -->
<add key="FxLog4NetConfFile" value="C:\root\files\resource\Log\SampleLogConf.xml" />
<!-- 埋め込まれたリソースの場合 -->
<!--<add key="FxLog4NetConfFile" value="_2CSClientWin_sample.SampleLogConf2CS.xml"/>-->
<!-- D層のパフォーマンスログ出力機能のon・off -->
<add key="FxSqlTraceLog" value="on" />
<!-- D層のSQL文キャッシュ機能のon・off -->
<!-- 開発フェーズのことを考慮して、デフォルトoffに設定 -->
<add key="FxSqlCacheSwitch" value="off" />
<!-- D層のSQLロード時のエンコーディングを指定(shift_jis、utf-8.etc) -->
<add key="FxSqlEncoding" value="utf-8" />
<!-- D層のコマンド タイムアウト値を指定(秒) -->
<add key="FxSqlCommandTimeout" value="30" />
<!-- セッションタイムアウト検出機能のon・off -->
<add key="FxSessionTimeOutCheck" value="on" />
<!-- 共通部品の使用するパラメータ - end -->
<!-- アプリケーションの使用するパラメータ - start -->
<!-- OAuth2, OIDC認証 -->
<add key="OAuth2AndOidcIsser" value="http://jwtssoauth.opentouryo.com"/>
<add key="OAuth2AndOidcClientID" value="f53469c17c5a432f86ce563b7805ab89"/>
<add key="OAuth2AndOidcSecret" value="cKdwJb6mRKVIJpGxEWjIC94zquQltw_ECfO-55p21YM"/>
<add key="OAuth2AndOidcRS256Cer" value="C:\root\files\resource\X509\SHA256RSA_Server.cer"/>
<add key="JwkSetUri" value="https://localhost:44300/MultiPurposeAuthSite/jwkcerts/"/>
<!-- SQLファイルファイル(フォルダ)へのパス -->
<add key="SqlTextFilePath" value="C:\root\files\resource\Sql" />
<!-- キャッシュ制御機能のon・off -->
<add key="FxCacheControl" value="ON"/>
<!-- アプリケーションの使用するパラメータ - end -->
</appSettings>
<?xml version="1.0" encoding="utf-8"?>
<!--
ASP.NET アプリケーションを構成する方法の詳細については、
http://go.microsoft.com/fwlink/?LinkId=152368 を参照してください
-->
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
<!-- SQL Server / SQL Client用 -->
<add name="ConnectionString_SQL" connectionString="Data Source=localhost\sqlexpress;Initial Catalog=Northwind;Integrated Security=True;" />
<!-- Multi-DB / OLEDB.NET用 -->
<add name="ConnectionString_OLE" connectionString="Provider=SQLNCLI10.1;Data Source=localhost\sqlexpress;Integrated Security=SSPI;Initial Catalog=Northwind;" />
<!-- Multi-DB / ODCB.NET用 -->
<add name="ConnectionString_ODBC" connectionString="Dsn=odbc_test1" />
<!-- Oracle / ODP.NET用 -->
<add name="ConnectionString_ODP" connectionString="User Id=SCOTT;Password=tiger;Data Source=localhost/XE;" />
<!-- DB2 / DB2.NET用 -->
<add name="ConnectionString_DB2" connectionString="Server=localhost:50000;Database=SAMPLE;User ID=db2admin;Password=seigi@123" />
<!-- HiRDB / HiRDBデータプロバイダ用 -->
<add name="ConnectionString_HIR" connectionString="DataSource=C:\\Windows\\HiRDB.ini;UID=APPUSER;PWD=STDDB;" />
<!-- MySQL / MySQL Connector/NET用 -->
<add name="ConnectionString_MCN" connectionString="Server=localhost;Database=test;User Id=root;Password=seigi@123;Allow User Variables=True" />
<!-- PostgreSQL / Npgsql用 -->
<add name="ConnectionString_NPS" connectionString="HOST=localhost;DATABASE=postgres;USER ID=postgres;PASSWORD=seigi@123;" />
</connectionStrings>
<appSettings file="app.config" />
<system.web>
<!-- リリース時は、debug="false"に変更してください。 -->
<compilation debug="true" targetFramework="4.6" />
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<!--
If you are deploying to a cloud environment that has multiple web server instances,
you should change session state mode from "InProc" to "Custom". In addition,
change the connection string named "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->
<!-- インプロセス -->
<!--sessionState timeout="20" cookieless="false" mode="InProc"></sessionState-->
<!--
ステートサーバ(利用の際は、管理ツール「サービス」から、ASP.NET 状態サービスを開始しておくこと。)
開発フェーズでステートサーバを選択しておけば、本番環境は、どのモードにも対応できる。
-->
<!--
If you are deploying to a cloud environment that has multiple web server instances,
you should change session state mode from "InProc" to "Custom". In addition,
change the connection string named "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->
<sessionState cookieName="mvc_session" timeout="20" cookieless="false" mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" />
<!--
SQLサーバ(利用の際は、以下のスクリプトを実行する)
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
・InstallSqlState.sql(UninstallSqlState.sql)
・InstallPersistSqlState.sql(UninstallPersistSqlState.sql)
[HOWTO]:ASP.NETで永続的なSQLServerセッション状態管理を構成する方法
http://support.microsoft.com/default.aspx?kbid=311209
[HOWTO]:SQL ServerでASP.NETセッション状態管理を構成する方法
http://support.microsoft.com/kb/317604/ja
↓環境構築には以下のツールを使用する。
ASP.NET SQL Server 登録ツール (Aspnet_regsql.exe)
http://msdn.microsoft.com/ja-jp/library/ms229862%28VS.80%29.aspx
※ Express Editionは、SQL Server 2005以降、SQL Serverエージェントを搭載しないので利用できない。
-->
<!--sessionState cookieName="mvc_session" timeout="20" cookieless="false" mode="SQLServer"
sqlConnectionString="Data Source=seigi-cmn-pc4;User ID=sa;Password=sa;"/-->
<!--
Oracleサーバ(利用の際は、以下のスクリプトを実行する)
C:\app\Administrator\product\11.1.0\client_1\ASP.NET\SQL
・InstallOracleSessionState.sql(UninstallOracleSessionState.sql)
・InstallOracleSessionState92.sql(UninstallOracleSessionState92.sql)
Oracle Providers for ASP.NET開発者ガイド > Oracle Providers for ASP.NETのインストール
http://otndnld.oracle.co.jp/document/products/oracle11g/111/windows/E06106-01/IntroInstallation.htm
Oracle Providers for ASP.NET開発者ガイド > OracleSessionStateStoreクラス
http://otndnld.oracle.co.jp/document/products/oracle11g/111/windows/E06106-01/OracleSessionStateStoreClass.htm
-->
<!--sessionState cookieName="mvc_session" timeout="20" cookieless="false" mode="Custom" customProvider="MyOracleSessionStateStore">
<providers>
<add name="MyOracleSessionStateStore"
type="Oracle.Web.SessionState.OracleSessionStateStore,
Oracle.Web, Version=2.111.6.20, Culture=neutral,
PublicKeyToken=89b483f429c47342"
connectionStringName="ConnectionString_ODP"/>
</providers>
</sessionState-->
<!--
認証の設定
このセクションは、アプリケーションの認証ポリシーを設定します。
使用できるモードは、"Windows"、"Forms"、"Passport" および "None" です。
詳細は、下記URLを参照のこと。
http://msdn2.microsoft.com/ja-jp/library/532aee0e.aspx
http://msdn2.microsoft.com/ja-jp/library/532aee0e(VS.80).aspx
-->
<!-- Windows認証 -->
<!--authentication mode="Windows" /-->
<!-- Forms認証 -->
<authentication mode="Forms">
<!--
本設定のパラメタは、別途検討すること。
属性 :目的
name :認証チケットを保存するクッキーの名前に使われる。
loginUrl :ログイン・フォームのURL
defaultUrl :認証後のリダイレクトに使用する既定の URL を定義する。
timeout :チケットの有効期間(単位:分)。
protection :クッキーの暗号化と検証の有無を指定(推奨値は、「All」)
path :クッキーのパス(既定値は、「/」)。
domain :フォーム認証 Cookie に設定するオプションのドメインを指定する。
requireSSL :認証 Cookie を送信するために SSL 接続が必要かどうかを指定する(既定値は、「false」)。
slidingExpiration :スライド式有効期限が有効かどうかを指定する(既定値、推奨値は、「true」)。
enableCrossAppRedirects :アプリケーション間のフォーム認証を可能にする。
cookieless :Cookie を使用するかどうか、および Cookie の動作を定義する。
詳細は、下記URLを参照のこと。
http://msdn2.microsoft.com/ja-jp/library/1d3t3c61.aspx
http://msdn2.microsoft.com/ja-jp/library/1d3t3c61(VS.80).aspx
-->
<forms name="formauth" loginUrl="Home/Login" defaultUrl="Home" timeout="10" protection="All" path="/" domain="" requireSSL="false" slidingExpiration="true" enableCrossAppRedirects="false" cookieless="UseDeviceProfile" />
</authentication>
<!--
権限の設定
このセクションは、アプリケーションの権限のポリシーを設定します。
この設定により、ユーザーまたはロールによるアプリケーション
リソースへのアクセスを許可したり、拒否したりできます。
ワイルドカード : "*" は全員を、"?" は匿名 (未認証) ユーザーを表します。
詳細は、下記URLを参照のこと。
http://msdn2.microsoft.com/ja-jp/library/8d82143t.aspx
http://msdn2.microsoft.com/ja-jp/library/8d82143t(VS.80).aspx
-->
<authorization>
<!-- 全ユーザーへの許可 -->
<!--allow users="*" /-->
<!-- 匿名ユーザーの禁止 -->
<deny users="?" />
<!--
<allow users="[ユーザーのコンマ区切り一覧]"
roles="[ロールのコンマ区切り一覧]"/>
<deny users="[ユーザーのコンマ区切り一覧]"
roles="[ロールのコンマ区切り一覧]"/>
-->
</authorization>
<!-- 偽装する場合は以下を有効にする -->
<!-- identity impersonate="true" userName="xxxx" password="xxxx" / -->
<!-- Onでない場合は、OnExceptionメソッドが動かない -->
<customErrors mode="RemoteOnly" />
<!--
ASP.NETの処理方法、実行時設定をする。
maxRequestLength:POSTデータの最大値(既定値は 4,096 KB (4 MB))
executionTimeout:POST処理の実行タイムアウトを設定(既定値は 90 秒)
詳細は、下記URLを参照のこと。
http://msdn2.microsoft.com/ja-jp/library/e1f13641.aspx
http://msdn2.microsoft.com/ja-jp/library/e1f13641(VS.80).aspx
-->
<httpRuntime targetFramework="4.6" maxRequestLength="4096" executionTimeout="90" />
</system.web>
<!-- ファイルをForms認証対象外にする -->
<!--JS/CSSをバンドルしたフォルダ-->
<location path="bundles"><system.web><authorization><allow users="*" /></authorization></system.web></location>
<!--エラー画面-->
<location path="Error"><system.web><authorization><allow users="*" /></authorization></system.web></location>
<!--外部ログイン-->
<location path="Home/OAuth2AuthorizationCodeGrantClient"><system.web><authorization><allow users="*" /></authorization></system.web></location>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
@daisukenishino
Copy link

daisukenishino commented Apr 22, 2019

補足

app.config

FxCacheControl

削除した場合、OFF扱いになるので「キャッシュ制御を行わない場合」、本設定を削除して問題無いと思います。ただ、業務系の動的ページは、通常、キャッシュ無効化を,設定した方がイイ気もします(CDNだと動的ページのキャッシュなどもやっているらしいですが)。

Web.config

configSections > sectionGroup > section

以下は、新規作成 > プロジェクトですると、View以下のWeb.configに設定される。
View以下のWeb.configに移動してもイイですが、問題なければ、このままにしておいて下さい。

  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" />
    </sectionGroup>
  </configSections>

認証・認可に関連する設定

認証を設定しない場合、authentication要素とauthorization要素、
また、location要素のauthorization要素は、子要素含めて削除してもイイ

customErrors > mode

未処理の例外のハンドリング方法を指定する。remoteOnlyが既定値。
また、HTTPステータスコードごとの例外画面などを設定可能。

# mode値 説明
1 On 未処理の例外が発生したときは、すべての閲覧者に対し、「ランタイムエラー」ページまたはユーザーフレンドリなカスタムのエラーページを表示します。
2 Off 未処理の例外が発生したときは、すべての閲覧者に対し、例外の詳細ページを表示します。
3 remoteOnly リモートユーザー(ローカルホスト以外から閲覧しているユーザー)に対しては、「ランタイムエラー」ページまたはユーザーフレンドリなカスタムのエラーページを表示します。ローカルユーザー(通常は開発者)に対しては、例外の詳細ページを表示します。

validation > validateIntegratedModeConfiguration

これは、新規作成 > プロジェクトで生成されるので、そのままにしておいて下さい。

<validation validateIntegratedModeConfiguration="false" />

アセンブリ バージョンのリダイレクト

ライブラリ側のDLLバージョンが、アプリケーション側のDLLバージョンより新しい場合など、コンポーネント毎にDLLバージョンが不一致している場合は、「アセンブリ バージョンのリダイレクト」を設定する必要がある。これらの設定は、Visual Studioによって自動生成されることがある。

問題なければ、このままにしておいて下さい。必要に応じて変更して下さい。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment