简体   繁体   English

ASP.NET Web应用程序中的多个Web.Config文件

[英]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" . 我有一个ASP.NET Web应用程序,我在根文件夹中有多个子目录。在我的根web.config中,我将sessionMode作为“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. 如果我将SessionMode方法更改为“InProc”,它将正常工作。 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 ? 我想在根目录中维护web.config文件,因为它是。所以我打算在子目录中有另一个web.config文件。任何人都可以告诉我如何做到这一点?

Thanks in advance 提前致谢

While you can have a Web.config in every subdirectory not all settings are allowed at all levels. 虽然您可以在每个子目录中都有一个Web.config,但并不是所有级别都允许所有设置。

And SessionMode is one setting that can only be made in the application-root. SessionMode是一个只能在application-root中创建的设置。

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

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

Just put another web.config in the subdirectory. 只需在子目录中放入另一个web.config即可。 ASP.NET allows for that, and I have several areas on my website where the web.config contains values specifically for that "application" specifically. ASP.NET允许这样做,我在我的网站上有几个区域,其中web.config包含专门针对该“应用程序”的值。

That said: 那说:

1) Are you sure it's a good idea to maintain state in two different ways? 1)你确定以两种不同的方式维持状态是个好主意吗? 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. 2)如果你不小心你在每个文件中放置了什么值,那么所有这些web.config文件都很难维护。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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