1
namespace ABC.Web.API.App_Start
{
    public class CustomFilterAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            SecureResponse response = new SecureResponse();
            try
            { 
                string rawURL = actionContext.Request.RequestUri.Query;
                object request;
                SecureRequest secureRequest = new SecureRequest();
                if (actionContext.ActionArguments.TryGetValue("request", out request))
                {
                    secureRequest = (SecureRequest)request;
                }

                secureRequest.DecryptedReqest = class.method(arg1,arg2);

            }
            catch (CustomException cex)
            {
                throw cex;
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
           base.OnActionExecuting(actionContext);
        }
    }
}

[HttpPost]
        [CustomActionFilter]
        public SecureResponse CustomAction(SecureRequest request)
               {

            SecureResponse response = new SecureResponse();
            try
            {
            }
catch (CustomException cex)
            {
               //whatever rethrown in actionfilterattribute catch(CustomException cex) should be caught here
            }
            catch (System.Exception ex)
            {
                //whatever rethrown in actionfilterattribute catch(System.Exception cex) should be caught here
            }
4

0 回答 0