0

I was wondering if it's a good/bad practice to access database from ASP.NET MVC action attributes?

Thank You

0

1 Answer 1

2

Like any good question, it depends.

I think it's probably not a great idea to do it in a filter if you're grabbing large amounts of data. However, getting one or two rows might be fine (even better if your data is cached)

This does have a certain appeal for data that just shows up. For example, using an ActionFilter to get the currently logged in user & store it in ViewData can save you a lot of code.

Final Answer: It's a judgement call.

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.