开发者

If user = XXX visitor, prompt for email...?

I'm trying to code a site where every 10,000th visitor is prompted to enter an email which can be stored in a text file.

I have a hit counter set up where it outputs the total visitors to a text file, so is it possible to set up a script to something like

"If number =*(10,000) from visitor.txt then prompt for email save to =emails.txt"

(I have zero programi开发者_开发技巧ng experience, thats just what i imagine it would be sorta like)

This is not for a spam site or anything, I have a real use :)


Here's what I'd do:

  1. In the Global.asax, add a step to the application start event to use System.IO to read the current user count from a separate file.

  2. In the Global.asax, add a step to the session start event to increment the counter and check if the current user is one of your special users. If the user is a 'special user' then store the users REQUEST URL and then forward to your email entry page.

  3. (Special Users Only) Write a page to accept the email address and anything else you want to save. Use System.IO to read and write to your emails.txt file. Once done, return user to the original REQUEST URL.

  4. In Global.asax, add a step to the application application end event to use System.IO to write the new current user count to file.


Check out the System.IO.File class for opening, reading and writing text files.

Depending on the volume of traffic to your site, you might be better off storing this information in a database.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜