0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vb.netの設定ファイルweb.configのメモ書き!

Last updated at Posted at 2019-06-20

vb.netでの設定ファイルでもある『web.config』について自分が苦労した内容を抜粋しました。

  • 受信データ容量のサイズアップ <system.serviceModel>
  • RESTコントローラの指定 <system.serviceModel>
  • レスポンスのフォーマット形式をJSONにする <system.serviceModel>
  • ログファイル、My.Application.Logの設定<system.diagnostics>

・受信データ容量のサイズアップ <system.serviceModel>

多めのデータをJSONで送信しようとしたら『413 Request Entity Too Large』のエラーがでたので
webHttpBindingタグで各サイズを指定します。
※サンプルは『basicHttpBinding』ばかりでしたが、これだと自分の環境では解決できなかったので『webHttpBinding』を使います


        <bindings>
            <webHttpBinding>
                <binding maxBufferPoolSize ="2147483647" maxBufferSize ="2147483647" 
                         maxReceivedMessageSize ="2147483647" />
            </webHttpBinding>
        </bindings>

・RESTコントローラの指定 <system.serviceModel>


      <services>
         <service name="proc1.Test1">
            <endpoint address="" behaviorConfiguration="proc1.Proc1Behavior" 
                      binding="webHttpBinding" contract="proc1.Test1" />
         </service>
         <service name="proc1.Test2">
            <endpoint address="" behaviorConfiguration="proc1.Proc1Behavior" 
                      binding="webHttpBinding" contract="proc1.Test2" />
            </service>
        </services>

・レスポンスのフォーマット形式をJSONにする <system.serviceModel>

defaultOutgoingResponseFormatでJsonに設定
※これがないとJSONに余分な値がセットされる

        <behaviors>
            <endpointBehaviors>
                <behavior name="proc1.Proc1Behavior">
                    <!--	<enableWebScript />  	-->
                    <webHttp defaultOutgoingResponseFormat="Json" />
                </behavior>
        </behaviors>

・ログファイル、My.Application.Logの設定<system.diagnostics>


    <system.diagnostics>
        <sources>
            <source name="DefaultSource" switchName="DefaultSwitch">
                <listeners>
                    <add name="FileLogListener" />
                </listeners>
            </source>
        </sources>
        <switches>
            <add name="DefaultSwitch" value="Information" />
        </switches>

        <sharedListeners>
            <!--    下記プロパティはデバックで警告になるが、実行はできるので無視する
                ・"autoflush"                : 自動的にフラッシュの指定  
                ・"location"               : ログの保存場所を変更する  
                ・"basefilename"             : ログファイル名  
                ・"customlocation"           : 出力フォルダ名             ※※ ここを環境に合わせて修正する ※※ 
                ・"logfilecreationschedule"  : ログファイル名の最後に日付を付加する 
                                                 "バイク検索システムエラーログ-2019-06-14.log"
            -->
            <add name="FileLogListener" 
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener,
                 Microsoft.VisualBasic, Version=8.0.0.0,
                 Culture=neutral, 
                 PublicKeyToken=b03f5f7f11d50a3a" 
                 initializeData="FileLogListenerWriter" 
                 autoflush="true" 
                 location="Custom" 
                 basefilename="バイク検索システムエラーログ" 
                 customlocation="C:\file\ログ\" 
                 logfilecreationschedule="Daily" />
        </sharedListeners>
    </system.diagnostics>

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?