简体   繁体   中英

Multiple Web.Config files in ASP.NET web application

I have an ASP.NET web application where i am having multiple subrirectories in the root folder.in my root web.config, i have sessionMode as "StateServer" . So in one page of my subdirectory, i am not able to do serialization. If i change the SessionMode method to "InProc" , it will work fine. I want to maintain the web.config file in the root directory as it is.So i am planning about having another web.config file in sub directory.Can anyone tell me how to do this ?

Thanks in advance

While you can have a Web.config in every subdirectory not all settings are allowed at all levels.

And SessionMode is one setting that can only be made in the application-root.

您可以在子目录中放置一个新的web.config文件,ASP.NET将覆盖您在该目录中更改的任何设置。

如果使用[Serializable]属性标记要放入Session的类,则通常可以在StateServer设置中使用它。

Just put another web.config in the subdirectory. ASP.NET allows for that, and I have several areas on my website where the web.config contains values specifically for that "application" specifically.

That said:

1) Are you sure it's a good idea to maintain state in two different ways? It would probably be better to figure out how to make your session state serializable or get rid of using session state altogether.

2) All those web.config files can get tough to maintain if you're not careful about what values you put in each.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM