Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6110869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:33:54+00:00 2026-05-23T14:33:54+00:00

I would like my ASP.NET MVC app to execute a query once per day.

  • 0

I would like my ASP.NET MVC app to execute a query once per day. What is the recommended way to do this?

My first thought is to put a timer in Global.asax that goes off every 24 hours, then call my query from the Elapsed handler. Any pitfalls with doing it this way? Is there a better way?

Edit

Let me add a little detail to what I’m trying to do. I’d specifically like the query to execute at midnight every day. If a day is missed (say due to sever maintenance or upgrading the app), that wouldn’t be a major issue.

Edit 2

Couple more details:

  1. The query is actually an INSERT, not a SELECT. The purpose is to add a “renewal” record for any member that is due to renew his/her membership at the end of the month.
  2. I’m using SQL Server Compact (it’s a very small database).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:33:55+00:00Added an answer on May 23, 2026 at 2:33 pm

    Does it have to originate in the Web layer? Who’d be there to consume the HTML? Typically, periodic SQL queries are scheduled within the database. In case of MS SQL Server – via the SQL Agent job facility. SQL Server can even send e-mail.

    RE: edit2: Should’ve told so right away. SQL Server Compact is not the same as SQL Server – for one, it does not have SQL Agent IIRC. Still, invoking the Web layer is an overkill. I’d use a Windows Scripting Host file (.js) in conjuction with Windows task scheduler. WSH files can connect to databases via ADO and do whatever they want – inserts, selects, anything.

    To detect missed scheduled runs, introduce an extra table with a log of scheduled runs. Then on subsequent runs you can analyse the date of the last run and act accordingly.

    Edit2: so no administrative access. You should really tell all those details in the question. In this case, I would go through the Web layer after all, but the scheduling would be on MY end – where I do have control. Have Task Scheduler run on your end and invoke an HTTP URL on the server. To invoke URLs, you can use something like the free CURL utility. Running IE in scheduled manner has the disadvantage of leaving the window open.

    IIS is not a scheduling engine.

    Edit3 re:comment: sorry, I’ve misunderstood the nature of your setup. My own experiences have clouded my judgement 🙂 Can you just run a check during every logon operation, and if it’s been a while since the last maintenance operation, run it right then and there? How long does the maintenance take? If it’s ~1min+, makes sense to run it in a worker thread, so that the logging-on user is not made wait.

    Scheduling daily maintenance is a good idea in general, and it is implemented fairly often, but it seems you simply don’t have the capability.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to setup a multi-tenant ASP.NET MVC app. Ideally, this app would
I am embarking upon my first ASP.NET MVC project and I would like to
Within a C# / ASP.NET MVC web app, I would like to display HTML
I'm developing my first ASP.NET MVC app and what I'd like to accomplish is
I'm using ASP.NET MVC Preview 4 and would like to know how to use
I would like to inject a dependency into an ASP.NET MVC model, but I
We have an asp.net mvc application that we would like to integrate a FileSystemWatcher
I would like to add graphing to my User Controls in ASP.NET MVC. I
I would like to cache my most database heavy actions in my asp.net-mvc site.
I would like to render a list of HTML links in ASP.NET MVC. Note

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.