All notes


RecurringJob.AddOrUpdate(()=>System.IO.File.AppendAllLines(@"d:\cron.txt", new string[] {System.DateTime.Now.ToLongTimeString()}), Cron.Minutely());

Configuration configuration.

    // Use connection string name defined in `web.config` or `app.config`

    // Use custom connection string
    .UseSqlServerStorage(@"Server=.\sqlexpress; Database=Hangfire; Integrated Security=SSPI;");

ConnectionString sql connection.

// Standard Security
Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;
// Trusted Connection
// Connection to a SQL Server instance
// The server/instance name syntax used in the server option is the same for all SQL Server connection strings.
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;


Recurring jobs

Example. Start time: 8:13 End time: 21:32 Interval: 15 minutes. Run everyday. stackOverflow: hangfire set end time for recurring job.

RecurringJob.AddOrUpdate(() => Console.Write("MyJob!"), "13-59/15 8 * * *");
RecurringJob.AddOrUpdate(() => Console.Write("MyJob!"), "*/15 9-20 * * *");
RecurringJob.AddOrUpdate(() => Console.Write("MyJob!"), "0-32/15 21 * * *");

// First line says between the minutes of 13 and 59, for hour 8, run every 15 minutes.
// Second line says for the hours 9 - 20, run every 15 minutes
// Third line says for the minutes 0-32, for hour 21, run every 15 minutes.


Error: No assembly found containing an OwinStartupAttribute

The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No assembly found containing a Startup or [AssemblyName].Startup class.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.


Add the following in web.config, to disable OWIN startup discovery as the error hints:

    <add key="owin:AutomaticAppStartup" value="false" />
</appSettings> forum. Startup.cs is from the MVC5 template. If you use MVC4, then there will be a problem. wcfNote: owin only supports MVC newer than 5?

Mathematical formulae powered by MathJax.