Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3807934
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:04:08+00:00 2026-05-19T15:04:08+00:00

I have some custom validation attribute classes in my model class that needs to

  • 0

I have some custom validation attribute classes in my model class that needs to be validated against a session object. How can this be achieved? In the model class, I cannot reference the current session object. Is there a way to somehow pass the session object into the model for validation? Or should I do this in the controller instead? And if I do it in the controller, how do pass back the error message back into the model class so that it shows up in my view page? This is for asp.net mvc 2.

thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:04:09+00:00Added an answer on May 19, 2026 at 3:04 pm

    You can always HttpContext.Current.Session inside your custom validation attribute (damn I already feel guilty for saying this). And if you don’t like this approach there’s the ModelValidator class in which you have the current HTTP context. Here’s a blog post illustrating the concept.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a validation class which needs improving. If I require some custom validation
I have some custom logic that needs to be executed every single time a
I have authored some custom classes that I would like to create using XAML:
I’m having some problems with validation. I have created a custom validator called RequiredFieldRule
I have some custom type: [RdfSerializable] public class Item { [RdfProperty(true)] public string Name
I have a custom FrameLayout class which does some custom drawing on the OnSizeChanged
I have a custom composite control that contains a text box, some validators, as
I need some help - I am trying to use a custom validation attribute
i going to create some validation for custom object in my app. But i
I have some custom validation I'd like to do with jQuery. jQuery validation comes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.