Search Results

Search found 9 results on 1 pages for 'jemes'.

Page 1/1 | 1 

  • Membership and asp.net MVC

    - by Jemes
    I’m building a site that needs users created with different roles and permissions to access different areas of the site. I using mvc 2 but I can’t find much clear guidance on using the Membership tool with mvc to create accounts and roles etc. I tried the web configuration tool which works but I would like to administrate the site remotely. I used the aspnet_regsql tool so I can access the SqlMembershipProvider Schema in my Database. I also need to add more information to a user like profile info and a picture, would I add these to the membership tables or create separate tables for this? Any advice or help would be really helpful? Thanks Jemes

    Read the article

  • GetAllUsers - MVC

    - by Jemes
    I’m using the Membership Provider and would like to display a list of all the users and their First Name, Last Name etc using the GetAllUsers function. I'm having trouble understanding how to implement this function in MVC. Has anyone implemented this in MVC or is there an easier way to list all the users in my application? Any help or advise would be really helpful. Controller public ActionResult GetUsers() { var users = Membership.GetAllUsers(); return View(users); } View Model public class GetUsers { [Required] [DisplayName("User name")] public string UserName { get; set; } [Required] [DisplayName("User name")] public string FirstName { get; set; } } View <%= Html.Encode(item.UserName) %> Error The model item passed into the dictionary is of type 'System.Web.Security.MembershipUserCollection', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Account.Models.GetUsers]'.

    Read the article

  • Accessing Linq Values in ViewData

    - by Jemes
    I'm having trouble accessing the id, area and theme values in my ViewData. They are being set in my action filter but when I get to the Site.Master I don't have access to them. Any help or advice would be great. ActionFilter public override void OnActionExecuting(ActionExecutingContext filterContext) { int SectionID = Convert.ToInt32(filterContext.RouteData.Values["Section_ID"]); int CourseID = Convert.ToInt32(filterContext.RouteData.Values["Course_ID"]); if (CourseID == 0) { filterContext.Controller.ViewData["Styles"] = (from m in _dataContext.Styles where m.Area_ID == SectionID select new {theme = m.Area_FolderName }).ToList(); } else { filterContext.Controller.ViewData["Styles"] = (from m in _dataContext.Styles where m.Course_ID == CourseID select new { theme = m.Course_FolderName }).ToList(); } } } Site.Master <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" % <%@ Import Namespace="Website.Models" % <% foreach (var c in (IEnumerable<Styles>)ViewData["Styles"]) { Response.Write(c.Theme); }%>

    Read the article

  • DropDownList View Model

    - by Jemes
    I'm trying to produce a dropdownlist for GetAllRoles using the role provider. I can produce the drop down in a controller using ViewData but I would like to use a View Model to produce the dropdown, but I'm unsure of the best way to create the list using a View Model? public ActionResult GetAllRoles() { ViewData["Roles"] = new SelectList(Roles.GetAllRoles()); return View(); }

    Read the article

  • Route Links - Url.Action

    - by Jemes
    I'm trying to return my links so they display as /Area_1419.aspx/2/1. I've managed to get that result in example 2 but I don't understand why it works, as I would exspect example 1 below to work. I don't see how Example 2 knows to go to the Area_1419 controller? Route routes.MapRoute( "Area_1419 Section", "Area_1419.aspx/{section_ID}/{course_ID}", new { controller = "Home", action = "Index" } ); Links Example 1 <a href='<%=Url.Action("Area_1419", new { section_ID="2", course_ID="1" })%>'><img .../></a> Returns: /Home.aspx/Area_1419?section_ID=2&course_ID=1 Links Example 2 <a href='<%=Url.Action("index", new { section_ID="2", course_ID="1" })%>'><img .../></a> Returns: /Area_1419.aspx/2/1

    Read the article

  • Using MembershipCreateStatus in MVC

    - by Jemes
    How can I use the MembershipCreateStatus in my controller below to identify errors? My controller below creates a new user but I would like to catch any errors from CreateStatus and add the error to my modelstate. [HttpPost] public ActionResult CreateUser(user UserToCreate) { if (ModelState.IsValid) { // TODO: If the UserToCreate object is Valid we'll //Eventually want to save it in a database Membership.CreateUser(UserToCreate.Username, UserToCreate.Password, UserToCreate.Email); return Redirect("/"); } //Invalid - redisplay form with errors return View(UserToCreate); }

    Read the article

  • List of Users and Role using Membership Provider

    - by Jemes
    I’m trying to produce a view to show a list of users and their role using the built in membership provider. My model and controller are picking up the users and roles but I’m having trouble displaying them in my view. Model public class AdminViewModel { public MembershipUserCollection Users { get; set; } public string[] Roles { get; set; } } Controller public ActionResult Admin() { AdminViewModel viewModel = new AdminViewModel { Users = MembershipService.GetAllUsers(), Roles = RoleService.GetRoles() }; return View(viewModel); } View Inherits="System.Web.Mvc.ViewPage<IEnumerable<Account.Models.AdminViewModel>>" <table> <tr> <td>UserName</td> <td>Email</td> <td>IsOnline</td> <td>CreationDate</td> <td>LastLoginDate</td> <td>LastActivityDate</td> </tr> <% foreach (var item in Model) { %> <tr> <td><%=item.UserName %></td> <td><%=item.Email %></td> <td><%=item.IsOnline %></td> <td><%=item.CreationDate %></td> <td><%=item.LastLoginDate %></td> <td><%=item.LastActivityDate %></td> <td><%=item.ROLE %></td> </tr> <% }%> </table>

    Read the article

  • Roles Provider - AccountModel

    - by Jemes
    I'm adding the Roles provider to the built in AccountModel but having some problems adding GetAllRoles in my view using the Register View Model. View Model from AccountModel public class RegisterModel { UserName, Email Etc.... [Required] [DisplayName("AllRoles")] public SelectList AllRoles { get; set; } } Roles Service added to AccountModel public interface IRolesService { SelectList GetAllRoles(); } public class RolesService : IRolesService { public SelectList GetAllRoles() { var AllRoles = new SelectList(Roles.GetAllRoles()); return AllRoles; } } Register View Page Inherits RegisterModel Form... <div class="editor-label"> <%= Html.LabelFor(m => m.ConfirmPassword) %> </div> <div class="editor-field"> <%= Html.PasswordFor(m => m.ConfirmPassword) %> <%= Html.ValidationMessageFor(m => m.ConfirmPassword) %> </div> <%= Html.DropDownListFor(m => m.AllRoles)%> I'm not sure how to populate the DropDown list with all the Roles from the View Model. Any help would be really great!!

    Read the article

  • AccountModel into a Repository and Interface

    - by Jemes
    I'm trying to separate the default AccountModel in mvc2 into a separate interface and repository. I've created an Interface and Repository and copied over the code from the AccountModel. I can register users and create accounts but in Visual Studio I'm getting the error below on the AccountController (* below). Error 1 Inconsistent accessibility: parameter type 'Admin.Models.IMembershipService' is less accessible than method 'Admin.Controllers.AccountController.AccountController(Admin.Models.IMembershipService) public class AccountController : Controller { private IMembershipService MembershipService; public AccountController() : this(new dao_MembershipService()) { } public **AccountController**(IMembershipService repository) { MembershipService = repository; } Does anyone know how I could fix the error?

    Read the article

1