I am using MVC with C#. I need to take the user to a payment page if the user didn’t pay for an item. I need to have a common class to check this functionality and redirect to payment page.
Like inheriting all the controllers to a Base Controller. In that base controller i have to check this payment status for some controller and actions(i.e. ViewPage) and redirect to payment page.
Please someone suggest the best way to do this
Create a custom actionFilterAttribute like so (this example works from having your item stored in the session, but you could modify this as required):
Then you can simply add an attribute to all controller actions that require this check: