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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:52:15+00:00 2026-06-03T07:52:15+00:00

I’m trying to integrate OpenID into my MVC3 Razor application. The OpenID is working

  • 0

I’m trying to integrate OpenID into my MVC3 Razor application. The OpenID is working but when I try and test a User’s membership in a Role the test fails.

Two Roles:

“MainUser” with one user named “User”.
“GuestUser” with one user named “Guest”.

Here’s my form in my Logon.cshtml

<form action="Authenticate?ReturnUrl=@HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"])" method="post" id="openid_form">
<input type="hidden" name="action" value="verify" />
<div>
    <fieldset>
        <legend>Login using OpenID</legend>
        <div class="openid_choice">
            <p>
                Please click your account provider:</p>
            <div id="openid_btns">
            </div>
        </div>
        <div id="openid_input_area">
            @Html.TextBox("openid_identifier")
            <input type="submit" value="Log On" />
        </div>
        <noscript>
            <p>
                OpenID is service that allows you to log-on to many different websites using a single
                indentity. Find out <a href="http://openid.net/what/">more about OpenID</a> and
                <a href="http://openid.net/get/">how to get an OpenID enabled account</a>.</p>
        </noscript>
        <div>
            @if (Model != null)
            {
                if (String.IsNullOrEmpty(Model.UserName))
                {
                  <div class="editor-label">
                      @Html.LabelFor(model => model.OpenID)
                  </div>
                  <div class="editor-field">
                      @Html.DisplayFor(model => model.OpenID)
                  </div>
                  <p class="button">
                      @Html.ActionLink("New User ,Register", "Register", new { OpenID = Model.OpenID })
                  </p>
                }
                else
                {
                //user exist 
                  <p class="buttonGreen">

                    @Model.UserName,

                    @if (Roles.IsUserInRole("MainUser"))
                      { <a href="@Url.Action("Index", "Main")">Welcome @Model.UserName, Continue... </a> }

                    @if (Roles.IsUserInRole("GuestUser"))
                      { <a href="@Url.Action("Index", "Guest")">Welcome @Model.UserName, Continue... </a> }

                      <a href="@Url.Action("Index", "Main")">Role test failed for @Model.UserName  </a>
                  </p>
                }
            }
        </div>
    </fieldset>
</div>
</form>

I run the app and successfully authenticate with OpenId and get a green block containing:
User, Role test failed for User

This shows a successful logon as “User” and that it made it to the else code block but the IsUserInRole test failed.

If I add the not operator to the first test [ @if (!Roles.IsUserInRole(“MainUser”)) ] the test passes.

The question is why does “User” fail the IsUserInRole test. I’ve triple checked that I have all my Roles and Users spelled correctly and that the Users are in the proper Roles.

Any help appreciated.

  • 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-03T07:52:17+00:00Added an answer on June 3, 2026 at 7:52 am

    If you are only using OpenId without any support from FormsAuthentication that it could be that the RoleProvider does not know how to check the roles. The Roles.IsUserInRole method relies upon RoleProvider.IsUserInRole to check whether a currently active user belongs to the requested role. The actual return value of RoleProvider.IsUserInRole according to MSDN documentation is:

    true if the specified user is in the specified role for the configured
    applicationName; otherwise, false.

    This applicationName should be set in the web.config file. If you are not using RoleProvider then that is the reason why your check keeps failing. RoleProvider is defined as following in configuration/system.web:

    <roleManager enabled="true" cacheRolesInCookie="true">
        <providers>
            <clear />
            <add connectionStringName="YourDbConnectionString" 
                 applicationName="MySampleAppName"
                 name="AspNetSqlRoleProvider" 
                 type="System.Web.Security.SqlRoleProvider" />
        </providers>
    </roleManager>
    

    Of course, this expects you to store your roles in aspnetdb database. However, you can implement your own RoleProvider if this one does not suit you well.

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

Sidebar

Related Questions

I am trying to integrate OpenID into my website but I am discovering OpenID
I am trying to integrate a Hibernate application into a proprietary framework. My problem
I'm trying to integrate Jawr into my Spring application: <bean abstract=true id=jawrBase class=net.jawr.web.servlet.JawrSpringController> <property
I'm trying to integrate searchable help into my Java (Swing) application. I'm using docbook
I have authlogic and openid working correctly, and am trying to integrate oauth for
We are trying to integrate the System.Web.Providers membership management into a transaction using System.Transactions.TransactionScope
I'm trying to integrate Django's comment app into my site but with no success.
I am trying to integrate AdMob into my Android Application, and can get it
I'm trying to integrate a SNMP agent into a Windows application written in native
I am trying to integrate together JOTM and Hibernate EntityManager to test my EJBs

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.