title: How to run a console app in MVC
body: <p>I have Console Application written in C# that is scheduled to run everyday so using the Built in Windows Task Scheduler. Every time it runs the black console box pops up for the duration of it's execution and then closes. I am not writing anything to the console.</p>
  
  <p>1.I've found other questions with search results I did task scheduler.
  but I could not decide <strong>where</strong> I will write code in the ASP.Net Mvc web app.
  this is the code.
  I trying this one.</p>
  
  <pre><code>private void CreateTaskRunDaily()
  {
      using (TaskService ts = new TaskService())
      {
          TaskDefinition td = ts.NewTask();
          td.RegistrationInfo.Description = "My first task scheduler";
  
          DailyTrigger daily = new DailyTrigger();
          daily.StartBoundary = Convert.ToDateTime(DateTime.Today.ToShortDateString() + " 16:30:00");
          daily.DaysInterval = 1;
          td.Triggers.Add(daily);               
          td.Actions.Add(new ExecAction(@"C:/sample.exe", null, null));
          ts.RootFolder.RegisterTaskDefinition("TaskName", td);
      }
  }
  </code></pre>
  
  <p>I could not decide where should I put in practice.</p>
  
  <p>2.I want to register only once, when the program runs.Thereby adding again each time it runs, over and over.I need to prevent it.
  If there is any advice it helps a lot.</p>