Essentiall开发者_开发技巧y, this is what I have:
I have a view form for an object in MVC. On this form, I have a hyperlink. Every time that the user clicks the hyperlink, I would like an integer value inside of the object to increase by one, in addition to redirecting the user to a different page.
Is there a way to do this and keep track of how many times the link is clicked?
Thanks for any help that you can offer!
Yeah. Just have the link point to an MVC action that increments the value you want to increment before redirecting them to the action that they should actually go to.
Without more information, that's about as detailed as I can get.
The options are many. If it is one user then you could track this in any of the following: session, cookie, querystring, database or even LocalStorage.
If "the user" is just any user then cookies and LocalStorage are ruled out.
I'd imagine session is the easiest, assuming scale is not a major concern.
You have multiple options for this.
-> Save it in database
-> Session
-> increment value in the global variable
精彩评论