我可以在 global.asax 文件中设置自定义会话状态模式的连接字符串吗?

发布于 2024-08-20 12:36:38 字数 210 浏览 2 评论 0原文

我可以在 global.asax 文件中设置自定义会话状态模式的连接字符串吗? 我无法在 webconfig 文件中对连接字符串进行硬编码。 ,我将在运行时获取连接字符串,我可以在 global.asax 文件中设置自定义会话模式/sqlserver 会话模式的连接字符串(例如在应用程序 statrevent 或 aquirerequeststate 事件中)。如果是,该怎么做?

谢谢!

Can I set the connection string for custom session state mode in global.asax file?
I cannot hard code the connection string in the webconfig file. ,I will get the connection string at runtime,Can i set the connection string for custom sessionmode/sqlserver session mode in the global.asax file(like in application statrevent, or aquirerequeststate event.If YES How to do that?

Thanks!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烙印 2024-08-27 12:36:38

不,应用程序启动后就无法动态修改此设置。 本文 是在Application_Start 中测试是否需要设置连接字符串,如果是,则修改web.config,这将导致应用程序域重新加载。

恕我直言,管理不同环境中的不同连接字符串的更好方法是在构建过程中设置一个步骤,在部署之前对 web.config 进行必要的修改。

No, it is not possible to modify this setting dynamically once the application has started. A possible workaround as proposed in this article is to test in the Application_Start if the connection string needs to be set and if yes then modify web.config which will cause the application domain to reload.

IMHO a better way to manage different connection strings among different environments is to have a step in your build process that does the necessary modifications to web.config before deploying.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文