![](/img/trans.png)
[英]ASP.NET MVC 3 - Images not found if deploy as application on IIS 7.5
[英]hangfire is not running when i deploy my asp.net mvc-5 web application on iis 7.5
我正在开发一个 asp.net mvc-5 Web 应用程序。 我使用 nuget 工具在我的 Web 应用程序中安装了 hangfire 工具。
https://www.nuget.org/packages/Hangfire/
然后我创建以下startup.cs
类,每分钟调用一个方法如下:-
public class Startup
{
public void Configuration(IAppBuilder app)
{
GlobalConfiguration.Configuration
.UseSqlServerStorage("scanservice");
ScanningService ss = new ScanningService();
RecurringJob.AddOrUpdate(() => ss.HypervisorScan("allscan"), Cron.Minutely);
}
}
这是将被调用的方法的定义:-
public async Task<ScanResult> HypervisorScan(string FQDN)
{
但目前我在 IIS 7.5 上部署了我的应用程序,并且根本没有调用该方法。 任何人都可以对此提出建议吗?
谢谢
您的课程中缺少 OwinStartupAttribute。 添加它。 这告诉 OWIN 代码在启动时运行的位置。
此外,您不能直接在 Hangfire 中运行异步方法,因为错误明确指出。 因此,使用 Wait 调用包装该方法并将其传递给 Hangfire。
最后,您应该遵守 Async 方法应以 Async 后缀结尾的约定。 将ScanningService.HypervisorScan
重命名为ScanningService.HypervisorScanAsync
[assembly: OwinStartup(typeof(MyWebApplication.Startup))]
namespace MyWebApplication
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
GlobalConfiguration.Configuration
.UseSqlServerStorage("scanservice");
RecurringJob.AddOrUpdate(() => HypervisorScan(), Cron.Minutely);
}
public void HypervisorScan()
{
ScanningService ss = new ScanningService();
ss.HypervisorScanAsync("allscan").Wait();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.