Global.asax,我可以在生产服务器中更新它吗?
我的生产服务器中有一个 asp.net 网站,现在运行良好。现在我使用quartz.net 来执行计划任务,并在我的开发系统中对其进行了测试。我想将其移至生产服务器。
我的 global.asax 目前在生产服务器中:
void Application_Start(object sender, EventArgs e)
{
Application["Hits"] = 0;
Application["Sessions"] = 0;
Application["TerminatedSessions"] = 0;
ConfigureLogging();
}
我将把它更改为
void Application_Start(object sender, EventArgs e)
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// construct job info
JobDetail jobDetail = new JobDetail("mysSendMailJob", typeof(ScheduledMail));
// fire every day at 06:00
Trigger trigger = TriggerUtils.MakeDailyTrigger(06, 00);
SimpleTrigger trigger2 = new SimpleTrigger("myTrigger",
null,
DateTime.UtcNow,
null,
SimpleTrigger.RepeatIndefinitely,
TimeSpan.FromSeconds(60));
// start on the next even hour
trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow);
trigger.Name = "mySendMailTrigger";
// schedule the job for execution
sched.ScheduleJob(jobDetail, trigger2);
// Code that runs on application startup
Application["Hits"] = 0;
Application["Sessions"] = 0;
Application["TerminatedSessions"] = 0;
ConfigureLogging();
}
这些更改会更新还是会发生什么?
I have an asp.net website in my production server which running fine now. Now I am using quartz.net for scheduled tasks and in my development system I have tested it. I want to move it to production server.
My global.asax at present in production server:
void Application_Start(object sender, EventArgs e)
{
Application["Hits"] = 0;
Application["Sessions"] = 0;
Application["TerminatedSessions"] = 0;
ConfigureLogging();
}
and I am going to change it to
void Application_Start(object sender, EventArgs e)
{
ISchedulerFactory schedFact = new StdSchedulerFactory();
// get a scheduler
IScheduler sched = schedFact.GetScheduler();
sched.Start();
// construct job info
JobDetail jobDetail = new JobDetail("mysSendMailJob", typeof(ScheduledMail));
// fire every day at 06:00
Trigger trigger = TriggerUtils.MakeDailyTrigger(06, 00);
SimpleTrigger trigger2 = new SimpleTrigger("myTrigger",
null,
DateTime.UtcNow,
null,
SimpleTrigger.RepeatIndefinitely,
TimeSpan.FromSeconds(60));
// start on the next even hour
trigger.StartTimeUtc = TriggerUtils.GetEvenHourDate(DateTime.UtcNow);
trigger.Name = "mySendMailTrigger";
// schedule the job for execution
sched.ScheduleJob(jobDetail, trigger2);
// Code that runs on application startup
Application["Hits"] = 0;
Application["Sessions"] = 0;
Application["TerminatedSessions"] = 0;
ConfigureLogging();
}
Will these changes be updated or what will happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它没有预编译,那么您可以在服务器上拥有不同的文件。
如果它是预编译的,则无法在服务器上更改它。
要解决此问题,您可以使用编译符号来具有不同的 application_start 方法或具有定义要调用哪个方法的设置。
如果您使用 .Net 4,您可以拥有一个调试和发布 web.config 文件,您可以在其中设置某种条件,并在应用程序启动时检查它。
If it is not precompiled then you can have a different file on the server.
If it is precompiled you can't change it on the server.
To fix this you an use compilation symbols to have different application_start methods or have setting that defines which method to call.
If you are using .Net 4 you can have a debug and release web.config file you you could set some sort of condition in there and check for it when the app spins up.