Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-06-19
1
Medium Priority
?
1,210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 39260895
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

609 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