0

I have a web api 2 application where I am trying to configure somevalue on runtime for every request. So basically my application needs to look up the value from other service api which changes about 15 times during the day based on that it needs to log the paralytics (the requirement sounds bit wired but that's what it is!).

1st Approach: I thought I can retrieve the value from Owin startup class but not sure if I can make it configurable on every request.

2nd Approach: The another way I am thinking to do is to have the attribute for every action but that means I will have to remember to apply that attribute to every new action that I create.

So I am looking for best approach to handle this as I am new to web api!

1
  • 1
    You can do an attribute on the API Controller class which will apply to all actions Commented May 27, 2015 at 19:44

1 Answer 1

1

You can add global filter on owin startup which will be applied to each request:

    public class OwinConfiguration
    {
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            config.Filters.Add(new CustomActionFilterAttribute());

        }
    }

Where CustomActionFilterAttribute inherited from ActionFilterAttribute;

Links:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.