Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How do I trigger action filters placed to sub methods which I am calling from the directly requested action method ?

In the below example SubmitViolation method will be requested from view and based on operation type I am calling other methods. I need to check the authorize permissions based on the operation type. But the action filters are not firing for SaveViolation and CertifyViolation.

Note: As per my requirement I should not use multiple forms in view and call separate action methods for each operation


C#
[ValidateAntiForgeryToken]
[HttpPost] // action method requested directly from view
public ActionResult SubmitViolation(ViolationViewModel violationVM, string operation)
{
	if (operation == "Submit")
    {
		SaveViolation(violationVM); // calling sub methods based on operation value
    }
    else if (operation == "Certify")
    {
        CertifyViolation(violationVM);
    }
}

 // StaffAuthorize is custom authorize filter that accepts type of operation and checks the authorization permissions

 [StaffAuthorize(Enums.StaffFunction.Violations_Save)]
public ActionResult SaveViolation(ViolationViewModel violationVM)
{
    // Save Violation implementation
	
	return View();
}

[StaffAuthorize(Enums.StaffFunction.Violations_Certify)]
public ActionResult CertifyViolations(ViolationViewModel violationVM)
{
    //Certify Violations implementation

	return View();
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900