I was wondering if it’s a good/bad practice to access database from ASP.NET MVC action attributes?
Thank You
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.