开发者

Where should I check if website settings has filled successfully?

开发者 https://www.devze.com 2023-04-11 15:13 出处:网络
I am developing a website by ASP.Net. I have created settings/first-run page which I need it to run in the first time to fill some settings like smtp settings and some paths.

I am developing a website by ASP.Net.

I have created settings/first-run page which I need it to run in the first time to fill some settings like smtp settings and some paths.

I also need it to be run any time if the settings XML file is deleted or when the user clicks on i开发者_开发知识库ts link from admin section.

Where should I put the code which checks if settings is OK or not and if it's not OK it executes this page ...

I was thinking in putting in Session_Start but this means that this code will run 1 time only and then the page will load and the session starts and then the user can back to home page without completing it, in this case the check won't run again.

I am thinking in Application_BeginRequest but this will add some headache on server to run this code with every request.

What do you think the best technique to do this ???


I would go for Application_BeginRequest with additional caching of the validation result for a second.

However if you store your configuration entirely in web.config and your application is configured to restart every time the web.config is changed (default behavior), Application_Start would work too.


The place to put all of these setting is Web.config.

It has several sections for different purposes:

For connection strings to databases, you should use <connectionStrings> section. For app settings in general, you should use <appSettings> section.

To access each of these sections, you can use the ConfigurationManager class.

0

精彩评论

暂无评论...
验证码 换一张
取 消