0

SessionState 設定を InProc に変更するために、次のコードを使用しようとしています

string configPath = "/Default Web site";
System.Configuration.Configuration config =System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration( configPath);
System.Web.Configuration.SessionStateSection sessionSection = ( (System.Web.Configuration.SessionStateSection)config.GetSection( "system.web/sessionState" ) );
sessionSection.Mode = SessionStateMode.InProc;
sessionSection.AllowCustomSqlDatabase = false;
sessionSection.RegenerateExpiredSessionId = false;
sessionSection.Cookieless = System.Web.HttpCookieMode.UseCookies;
config.Save( );

しかし、うまくいきません。エラーはスローされませんが、Web サイトの構成に変更が見られません。config プロパティを調べると、構成ファイルのパスがなく、hasFile が false に設定されていることがわかります。

C# でこのプロパティを変更するにはどうすればよいですか?

4

0 に答える 0