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 8490095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:00:54+00:00 2026-06-10T22:00:54+00:00

So I have implemented my own custom membership provider, currently only overwriting ValidateUser(). I

  • 0

So I have implemented my own custom membership provider, currently only overwriting ValidateUser(). I also have signalr working, currently just a simple method that calls send message and then sends it out to all listeners. I would like to add some validation checking so that this command cannot be run on its own. So far I have found you can do this using: Context.User.Identity.IsAuthenticated

[HubName("messageController")]
public class MessageController : Hub
{
    public void SendMessage(string message)
    {
        if (Context.User.Identity.IsAuthenticated)      // this line not working
        {
            Clients.addMessage(message);
        }
        else
        {
            Clients.addMessage("not authenticated");
        }
    }
}

My problem though is because I am currently using a custom membership provider value is false. Is there something else I should be using here instead?

Currently when I Login I execute:

    [AllowAnonymous]
    [HttpPost]
    public ActionResult Login(LoginModel model, string returnUrl)
    {
        if(Membership.ValidateUser(model.UserName, model.Password))
        {
            // Need something here to actually set the logged in user
        }
        return RedirectToAction("Index", "");
    }

What am I missing here? Do I need to store my own code to handle the session, I tried using FormsAuthentication.SetAuthCookie(model.UserName, true); which worked but I’m pretty sure its wrong. When I tried to introduce Roles by changing it to Context.User.IsInRole("Admin") it returned false. even though I used the below User model (which when debugging never gets to this method):

public class User : IPrincipal
{
    [Required]
    [Display(Name = "User name")]
    public string UserName { get; set; }

    [Required]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }


    public long UserID;
    public string Name;
    public string ConnectionId;

    public virtual IIdentity Identity
    {
        get;
        set;
    }

    public virtual bool IsInRole(string role)
    {
       return true;
    }

}

I’m pretty confident I am missing something with this, any ideas?

  • 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-06-10T22:00:55+00:00Added an answer on June 10, 2026 at 10:00 pm

    Using FormsAuthentication.SetAuthCookie() after you’ve validated the user is perfectly OK, the default AccountController created by the MVC3 template does exactly the same.

    The reason why your call to Context.User.IsInRole() doesn’t work is because that won’t invoke your custom User class (the framework doesn’t know about it), instead it will try to get the roles via a RoleProvider. You need to build a custom provider and hook it up in the Web.config like you did with the membership provider.

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

Sidebar

Related Questions

We have implemented a Custom Membership provider and have a change password control on
I have implemented my own simple version of a navigation window, mainly because navigation
I have implemented my own custom Authorization Attribute in MVC 4 by inheriting from
I have implemented my own custom Logger for my django site: class SpecialLogger(logging.Logger): def
I am working on implementing a custom membership provider that works against an existing
I have own control implemented in CommonControls assembly (the same namespace). It us 'Custom
I currently have a Java EE application in which I have implemented my own
Symfony2 and FOS User Bundle issue... I have implemented my own login form in
I have an own Tree object implemented in PHP. Say we have a tree
I have implemented pagination to my data, but the problem is I only have

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.