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 7891367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:36:04+00:00 2026-06-03T06:36:04+00:00

I’m currently working on an e-commerce site and there’s one feature that i’m not

  • 0

I’m currently working on an e-commerce site and there’s one feature that i’m not very sure how to implement. Most of the time you just add product(s) to your cart and buy them, that’s probably the simplest workflow. What i’m asking is a little different, what if there’s a time limit for a product to buy ? I mean some sites give you an exact time limit to buy a product (like Soccer Manager), in those sites you can’t hold a product forever, there’s a 15 minutes limit for it and if you dont buy in that period, item will be released from your cart. (and most probably someone else will jump on it)

Now, as an ASP.NET MVC programmer i’d love to implement this feature but as i said, i’m not sure how to do it. I think when i add item to cart i need to hold the time (something like ItemAddedAt) and i need to release that item in x minutes so something needs to run x minutes later to release that product. Globally thinking, i think i need a service, when i add an item, i also need to subscribe it to this service and service runs a timer/job in the background. What i dont know/have no experience is this part, how to do that in an ASP.NET MVC project, is there a sample project, article, library or something like that ?

Of course i dont know if my logic is right for this problem, i need some guidance, if possible some source code to work on.

  • 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-06-03T06:36:05+00:00Added an answer on June 3, 2026 at 6:36 am

    AFAIK there are no standard way to declare/program tasks within an MVC project. The recommended way to accomplish what you want would be to create a new Console Application project within your solution, and use the Windows Task Scheduler to execute every X minutes, releasing any products that have been more than X minutes in any cart.

    For this to work, you will need to reference your MVC project from the new one (to get access to all the models) or, even better, create a Class Library project, move your Model/database classes there, and reference it from the MVC and Console projects.


    All that being said, there is actually a small “hack” that can be used to get programmed tasks in an MVC project. You can use the following code:

    HttpContext.Current.Cache.Add("Task", "1", null, 
                DateTime.MaxValue, TimeSpan.FromMinutes(5), 
                CacheItemPriority.Normal, new CacheItemRemovedCallback(CheckCarts));
    

    That line, that could be called, for example, from the Global.asax, would add a “Task” entry to the cache. The value stored (“1”) is not important, the important thing is that the cache entry expires in five minutes and, when expired, calls the “CheckCarts” method (defined in the Global.asax, or in the class were you execute this code).

    public void CheckCarts(string key, object value, CacheItemRemovedReason reason) {
         // Insert your code here to check for expired carts
         (...)
    
         // We add the entry again to the cache, so that this method will be called again in 5 minutes.
         HttpContext.Current.Cache.Add("Task", "1", null, 
                DateTime.MaxValue, TimeSpan.FromMinutes(5), 
                CacheItemPriority.Normal, new CacheItemRemovedCallback(CheckCarts));
    }
    

    When the cache expires, the CheckCarts method is called, your code does whatever it has to do, and in the end adds itself to the Cache again, to be called in another 5 minutes.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported

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.