asp.net-mvc-5

How to get Role.Name in Razor View?

不羁的心 提交于 2019-12-11 06:29:01
问题 I am using @model IEnumerable<WebApplication.Models.ApplicationUser> View @foreach (var user in Model) { <tr> <td> @foreach(var role in user.Roles){ role.Name; //invalid role.RoleId; //valid role.UserId; //valid } </td> </tr> } Model public class ApplicationUser : IdentityUser { [Required] public string FirstName { get; set; } [Required] public string LastName { get; set; } public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) { // Note the

How to make a custom paging in ASP.net MVC 5 depend on bootstrap? [closed]

半腔热情 提交于 2019-12-11 06:18:51
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . how can i add a custom paging to my application that's writing in C# MVC5 with using a database and Entity Framework 6 with Bootstrap ? 回答1: This is my code and its working properly : Note: this paging code need bootstrap to be exist Add new file in the models named paging.cs:

Compare attribute in nested class

馋奶兔 提交于 2019-12-11 06:16:09
问题 I want to reuse my User class in my UserViewModel because it is too big, with too many properties. public class User { [DataType(DataType.EmailAddress)] public string Email { get; set; } [DataType(DataType.Password)] public string Password { get; set; } /* ... many other properties */ } My UserViewModel have the property User and the ConfirmEmail and ConfirmPassword properties. public class UserViewModel { public User User; [DataType(DataType.EmailAddress)] [Compare("User.Email")] public

Apache and mono can't find the default controller and show the homepage

依然范特西╮ 提交于 2019-12-11 06:10:41
问题 I am going to host an asp.net MVC 5 website (.net framework) on ubuntu server. The asp.net MVC 5 project that I am using is an asp.net MVC template from MonoDevelop. (Very simple project) I have used apache2 and installed mono based on this tutorial: https://medium.com/@shrimpy/configure-apache2-mod-mono-to-run-asp-net-mvc5-application-on-ubuntu-14-04-314a700522b9? but it doesn't work and it only shows the directories and files when I go to 127.0.0.1:80 Here is the page I face on the browser:

ASP.NET MVC 5 model validation for non-nullable types (Int32)

Deadly 提交于 2019-12-11 05:45:02
问题 I'm working on an ASP.NET MVC 5 application and the project owner is concerned about "under-posting" issues caused by validating non-nullable types (as mentioned in http://bradwilson.typepad.com/blog/2010/01/input-validation-vs-model-validation-in-aspnet-mvc.html and http://www.asp.net/web-api/overview/formats-and-model-binding/model-validation-in-aspnet-web-api). I created a test case to replicate this issue in ASP.NET MVC 5 but without luck. Model: public class ContactModel { [Required]

How to write the Looping structure for Parent-Child relationships?

江枫思渺然 提交于 2019-12-11 05:44:49
问题 I am using treetable.js. as procedure i saved the child id and parent id. insert data is successfully inserted. but return data may show in table only or get the grouping error. then i use the IGrouping Object get the Convertion error. Please tell me the child parent loop structure for the below. In Model: public string name {get;set;} public int childId {get;set;} public int ParentId {get;set;} In Controller: var list = db.table.groupby(s=>s.parentId).toList(); return view(list); In view:

Cannot access properties of model in javascript

随声附和 提交于 2019-12-11 05:44:14
问题 I have tried a few suggestions on here however did not seem to work, I cannot seem to access the properties of the model. This is what I have so far var widgetModel = '@Html.Raw(Json.Encode(Model.widgets))'; [].forEach.call(widgetModel, function (widget) { var template = document.querySelector('#panel-template'); var panelTitle = template.querySelector('.panel-title'); panelTitle.textContent = widget.WidgetName; }); Here is the rendered widgetmodel http://gyazo.com

How to rewrite the OWIN-Cookie manually (MVC5)

我是研究僧i 提交于 2019-12-11 05:29:59
问题 I use the IUserSecurityStampStore to implement sign-out-everywhere functionality. It seems to work fine, however I have the problem that every time the user changes her password, she is logged off afterwards. One possibility to work around this issue, is to call SignIn in the Manage -Action of the AccountController after a password change. This seems to work, but I think it’s a bit clumsy and probably not the right way. Thats why my questions are: How can I force OWIN to rewrite the cookie

moving mvc5 account controller code to separate project

不问归期 提交于 2019-12-11 05:27:57
问题 I have a solution that contains a WebApi2,MVC5 & DAL project (all RTM). I am wanting to use the new membership bits that are now baked-in, but I don't like all the account stuff being all in the account controller. Doing a file new project (asp.net) has all of the membership stuff coupled to the account controller. Within my DAL I am using EF6 as I like the ideal of code-first as it suits what I am trying to do. I am trying to take the account controller code and move it into my separate

LINQ Group by string and count grouped property's child property

半世苍凉 提交于 2019-12-11 05:06:36
问题 I have written a code like below: Session["priceRange"] = ranges.Select(r => new PriceRangeGraph { Price = Math.Round(r, 2), Sales = lista.Where(x => ranges.FirstOrDefault(y => y >= x.SalePrice) == r).Sum(x => x.SaleNumber), SuccessfulSellers = lista.GroupBy(x => x.StoreName).Where(x => ranges.FirstOrDefault(y => y >= x.Select(z => z.SalePrice).FirstOrDefault()) == r && x.Select(h => h.SaleNumber).FirstOrDefault() > 0).Count(), UnSuccessfulSellers = lista.GroupBy(x => x.StoreName).Where(x =>