Solved

ASP.Net MVC 4 C# -- Roles.GetRolesForUser() "LIKE" statement ?

Posted on 2013-06-19
1
1,134 Views
Last Modified: 2013-06-20
I have 20+ roles that start with "BUICK"
How can I get the below "LIKE" statement working ?

I am MVC4 simpleMembership with the below SYSTEM generated database tables.
  webpages_UsersInRoles
  UserProfile
  webpages_Membership
  webpages_Roles

                               if (User.IsInRole("BUICK_LeadMan")) --below works
                               -- trying to do this instead, but it fails --> if (Roles.GetRolesForUser().LIKE("BUICK"))
                                   {
                                       <li>@Html.ActionLink("About1", "About", "Home")</li>
                                   }
0
Comment
Question by:finance_teacher
1 Comment
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
Hi finance_teacher;

You can try using the Linq method to achieve what you need.

if (Roles.GetRolesForUser().Any( u => u.StartsWith("BUICK")))
{ 
    <li>@Html.ActionLink("About1", "About", "Home")</li>
}

Open in new window

0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now