开发者

How to handle concurrency in an ASP.Net WebSite? (auctioneer site)

my problem is follow:

I have an auctioneer site, in which many different objects will be auctioneerd.

My problem is very simple to clear for an more experience user I thinK. How I can handle business and database logic without opened a site or them?

My problem is to say directly, if nights at 3 no user is on the site, the winner (e.g.) must be set - if a page is opened or not.

So I need some kind of "every 2 seconds, do this method"开发者_如何学C - without opened a site.

My idea was a sepereate application which uses the same business and database-layer as the asp.net page and let this run at the server. Is that a good or bad idea?


The separate process (scheduled app or Windows service) is the only reliable way you can achieve this.

Using the same BLL and DAL are exactly the right thing to do too.

Check out this article on windows services http://msdn.microsoft.com/en-us/library/aa984074(VS.71).aspx


To let every user query the database every 2 seconds would create unnecessary traffic on your site, which is not a good idea. (users tend to refresh the page many times just before the auction closes anyway)

My thoughts: Add a date to the auction when it closes. The last user that places a bid is always the winner, and you can't place bids after 3 am (the date the auction closes), so if you visit the site after 3 am (you can't place a bid and) the winning user is displayed. If somebody opens the site just before 3 am and places a bid after 3 am your business logic should check the date of the bid and deny it.. (also: users might live in different timezones so consider displaying the server time on your site). Setting the date to 'now' would close the auction immediately.

You can also add javascript to refresh the page if your clock passes the hour or something like that. (or use the number of seconds left before the auction closes in a setTimeout function or metarefresh)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜