asp.net-mvc-5

ASP.NET MVC 5 Get users from specific Role

一世执手 提交于 2019-12-01 13:47:47
How is it possible to show a List from all users in a specific role. I attach a IdentityRole model to my View with the 'Admin' role assigned to it. So far I only can get the UserId. @model Microsoft.AspNet.Identity.EntityFramework.IdentityRole @Html.DisplayNameFor(model => model.Name) // Shows 'Admin' @foreach (var item in Model.Users) { <tr> <td> @Html.DisplayFor(modelItem => item.UserId) </td> </tr> } A possible solution would be to create a List of the users in the controller and attach this to the View. The problem would be that I also need data from the Role itself. If you are using ASP

The activationCode is null in my method input when I click the email Verification link

一曲冷凌霜 提交于 2019-12-01 13:32:07
问题 In the name of God Hi all. I'm creating registration for my mvc 5 website in VS 2017.It has Email confirmation in it. the URL link for activation will be received completely in Email. when I click , it works and it exactly comes to my controller on the correct ActionMethod but I don't know why the activationCode is null! :| While before it worked correctly, I mean the Activation code was not null. I don't know what happend to it! Any help will be appreciated. Edited: public class RouteConfig

How i do Required If validation by function in MVC5

旧时模样 提交于 2019-12-01 13:28:43
问题 if email exist by function check i want display error how i do it? [RequiredIf(BL.datafuncs.checkIfExist(email) == true, ErrorMessage = "email already exist")] public string email { get; set; } 回答1: The RequiredIf attribute is for validating a property that is required based on the value of another property. For example if you model contains properties bool NotifyMeByEmail and string EmailAddess then you could apply it as follows. public bool NotifyMeByEmail { get; set; } [RequiredIf(

How to bind nested objects on HttpPost in ASP.NET MVC

若如初见. 提交于 2019-12-01 13:02:26
问题 I have started to implement this solution bind attribute include and exclude property with complex type nested objects but it does not work at all. The same question is here Binding nested model with MVC3 on HttpPost but no concrete answer. Model [Bind(Include = "FirstName,MiddleName,LastName,Position,TruckTypeID,Direction,Organization,Objective,TimeStart,TimeEnd")] public partial class UserRequestRegisterModel { [DisplayName("Имя")] [Required] public string FirstName { get; set; }

asp.net mvc-5 HttpPostedFileBase is null [duplicate]

独自空忆成欢 提交于 2019-12-01 12:48:38
问题 This question already has answers here : HttpPostedFileBase always return null in ASP.NET MVC (5 answers) Closed 2 years ago . i am messing around with file uploading using asp.net mvc-5 HttpPostedFileBase but it is showing me HttpPostedFileBase is null after i am selecting the image here is my code <input type="file" title="search image" file-model="profileimage" id="allfilepath" name="file" /> <button type="submit" class="btn btn-primary col-sm-5"> <span class="glyphicon glyphicon-plus"><

Two questions about MVC, and Identity

混江龙づ霸主 提交于 2019-12-01 12:39:15
问题 I am very new to identity and MVC, I am trying to create an MVC app as one of my first projects. I have been able to follow a few tutorials and have successfully added additional properties to my ApplicationUser : IdentityUser class public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { [Required] [Display(Name = "UserName")] [StringLength(50)] public string Handle { get; set; } [StringLength(100, ErrorMessage = "Your {0} can be

Two questions about MVC, and Identity

安稳与你 提交于 2019-12-01 12:12:09
I am very new to identity and MVC, I am trying to create an MVC app as one of my first projects. I have been able to follow a few tutorials and have successfully added additional properties to my ApplicationUser : IdentityUser class public class ApplicationUser : IdentityUser<string, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { [Required] [Display(Name = "UserName")] [StringLength(50)] public string Handle { get; set; } [StringLength(100, ErrorMessage = "Your {0} can be at most {1} characters long.")] [Display(Name = "First Name")] public string FirstName { get; set; }

Error while generating view in Visual Studio 2019

纵饮孤独 提交于 2019-12-01 11:54:38
While I am creating an ASP.NET MVC view in Visual Studio 2019, I am getting this error: There was an error running the selected code generator: 'the value -1 is outside the acceptable range 0,2147483647 How can I solve it? We have to open vs-2019 and select tool -> Options-> General -> ignore GPU memory access exception if the data written didn't change. Mark it as checked then error will be disappear. I ran into the same problem tomorrow, tried many manipulations found on different subjects, including yours, nothing worked. Finally, someone gave me a "solution" that let me continue my project

MVc 5 - validation german date with unobtrusiv js - a simple approach

非 Y 不嫁゛ 提交于 2019-12-01 11:41:07
The question: How get the unobtrusiv validation of a german date running in MVC? Because I can't find a running example of using globalize 1.x with MVC 5 to validate a german date I needed two days to get it running. The problems are the order of the js-files, getting the cldr-data and putting it all together in an way it can be reused. In the answer I will show my current solution. In this zip-file ( https://www.dropbox.com/sh/75dx6alck7itwia/AABFkcgOQVc1bUXFE_jYfR_da?dl=0 ) you find all files you need. It includes an short todo.txt (de and en) the cldr-data (jsons) in sub-directories a

How to Add new Row Dynamically in ASP.Net MVC 5

六眼飞鱼酱① 提交于 2019-12-01 11:37:18
I am looking for help on how to add a new row of LineItems to an Invoice in a create Razor view of an ASP.Net MVC 5 application. I have read almost all similar questions but none have addressed what I thought was a simple use case. Here is my Invoice model class public class Invoice { public int Id { get; set; } public int InvoiceNumber { get; set; } public List<LineItem> LineItems { get; set; } public Client Customer { get; set; } public DateTime DateCreated { get; set; } public decimal Total { get; set; } public Invoice() { LineItems = new List<LineItem>(); } Take note that this invoice