I have declared a static variable in my class and I want it to be cleared after it is being used. It is of int type.
Also, is there any controller function which is called when view gets unloaded? May be I can clear the variable there.
Please let me know if more info is required.
Update:
I am passing a value from my view to controller. Now, when my controller has this value, I want it to be sustained. For which I am using static.
For now it has proved to be handy. I welcome suggestions for a better solution. But please do provide me solution for current question 🙂
If you want to clear static variable – assign new value to it.
If you want to execute something prior/after controller action – use action filters. Custom action filter allows you to override following methods (and execute your logic there):
OnActionExecuting– called before a controller action is executed.OnActionExecuted– called after a controller action is executed.OnResultExecuting– called before a controller action result is executed.OnResultExecuted– called after a controller action result is executed.