asp.net-mvc-5

Combine my ApplicationsDbContext with IdentityDbContext no key defined using MVC 5

断了今生、忘了曾经 提交于 2019-12-06 12:37:22
I was combining my existing DBContext with the new IdentityDbContext in MVC 5. I managed to combine the two contexts but when I ran my application and the model was being created I was presented with the following error message: Context.IdentityUserLogin: : EntityType 'IdentityUserLogin' has no key defined. Define the key for this EntityType. Context.IdentityUserRole: : EntityType 'IdentityUserRole' has no key defined. Define the key for this EntityType. I worked out how to fix it after doing a bit of reading. Create the two following configuration classes (keeps it clean in your

RouteValueDictionary ignores empty values

北战南征 提交于 2019-12-06 12:13:11
I have few empty route values I want in the query string: var routeValues = new RouteValueDictionary(); routeValues.Add("one", ""); routeValues.Add("two", null); routeValues.Add("three", string.Empty); If I then pass it to UrlHelper.RouteUrl() it ignores all the values and the generated query string is empty. However, urls like /?one=&two=&three= are perfectly valid. How can I do that? This behavior is built into the default Route class. It calls into the ParsedRoute.Bind() method where it does this check: if (IsRoutePartNonEmpty(obj2)) { acceptedValues.Add(key, obj2); } Which does this:

Request Client Certificate

安稳与你 提交于 2019-12-06 12:08:28
I've seen a lot of unsolved questions about this. Apparently many developers have gotten past this issue, but I haven't seen any solutions posted. I'm trying to read a smart card (X.509 CAC) for my ASP.NET MVC 5 web app. When I try to pull the certificate information like this: var request = HttpContext.Request; var cert = request.ClientCertificate; The cert has empty values. The problem appears to be I am not presenting the dialog to request user certificate info like I see on other websites. How do I expose this dialog? I am running it with SSL enabled. My applicationhost.config has this in

ASP.NET MVC 5 Editor for 2-dimensional array

ぃ、小莉子 提交于 2019-12-06 11:45:05
I have a model with two-dimensional array in it: public class Matrix { public ValidInt[][] Data; [Range(0, 8, ErrorMessage = "Введите ширину картины")] public int Width { get; set; } [Range(0, 8, ErrorMessage = "Введите ширину картины")] public int Height { get; set; } public Matrix(int w, int h) { Width = w; Height = h; Data = new ValidInt[w][]; for (int i = 0; i < w; i++) this.Data[i] = new ValidInt[h]; } public class ValidInt { [Range(0, 8, ErrorMessage = "Введите число, соответствующее цвету")] public int Value { get; set; } public ValidInt() { Value = 0; } } } Then I would like to have

Want to move y-axis scrollbar with mouse wheel in highcharts/highstock

坚强是说给别人听的谎言 提交于 2019-12-06 11:41:47
问题 Referring to the question i want to move my y-axis scrollbar with mouse wheel Is there any way to do it ? yAxis: { scrollbar: { enabled: true, showFull: false }, } Updated Code Bellow is my updated code var chart1 = new Highcharts.Chart({ chart: { renderTo: 'container1', type: 'column', zoomType: 'xy', panning: true, panKey: 'shift', //type: 'column', //zoomType: 'xy', //panning: true, //pankey: 'shift', resetZoomButton: { position: { //align: 'right', // by default //verticalAlign: 'top', //

Creating a ViewModel from two EF Models in ASP.Net MVC5

人盡茶涼 提交于 2019-12-06 11:34:26
I have been searching around and really can not find a decent answer on how to build a ViewModel and then fill that with the data from my EF model. The two EF models I want to push into a single ViewModel are: public class Section { [DatabaseGenerated(DatabaseGeneratedOption.Identity), HiddenInput] public Int16 ID { get; set; } [HiddenInput] public Int64? LogoFileID { get; set; } [Required, MaxLength(250), Column(TypeName = "varchar"), DisplayName("Route Name")] public string RouteName { get; set; } [Required, MaxLength(15), Column(TypeName = "varchar")] public string Type { get; set; }

How to delete user with UserManager in mvc5

流过昼夜 提交于 2019-12-06 11:19:14
I'm using mvc5, and everything about user account management I do with UserManager. It works good with roles, claims, etc. But I didn't find how to delete user with UserManager. Is there a way to delete user with UserManager? I can create Database context with dbset and then delete it from this context, but I don't want create dbcontext, userclass, etc. for one delete method. Delete was not supported in UserManager in 1.0, but its supported in the upcoming 2.0 release, and in the current 2.0 nightly builds if you want to preview the changes early. I had issues with the above answer, though I

Verify User Permission on Action Filter or Authroize Filter?

谁说胖子不能爱 提交于 2019-12-06 11:10:48
I am developing a website in MVC4. I developed user roles and permissions. I want to ask where I should check user permission access: in the Custom Action filter, or the Custom Authorization filter? If user does not have access to the module, then I must show a toaster error message. How do I show this message in an action filter? I use to write custom action filter attribute so that on the action call this method is called and i check in it if user role allows him to call this action or not. You have to write custom action filter attribute same way but you have to write your own business

VB.NET and MVC 5 using custom helpers with in-built helpers and no App_Code

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 11:05:59
问题 I'm working on an MVC 5 project using VB.NET and EF 6. I have added an EditorTemplates nuget package which relies upon Custom Global Helpers. In C# I can merely add new helpers wherever as a public static class , then add the namespace to ~/Views/Web.config and off I go. To the best of my knowledge C# and VB.NET differ here greatly. After much battling with the compiler and Stack Overflow searching I found that I could get the custom helpers to work in views if placed them in the App_Code

AllowHtml attribute doesn't work

别说谁变了你拦得住时间么 提交于 2019-12-06 10:57:54
问题 I'm trying to implement Tiny MCE text editor to my Create page. I've used [AllowHtml] attribute to my Body property but it still doesn't work. My detail view for the blog still showing html tags. This is my blog entity class. public class Blog { public int Id { get; set; } [Required] public string Title { get; set; } [AllowHtml] [Required] [DisplayName("Content")] public string Body { get; set; } [DisplayName("Created on")] [DataType(DataType.Date)] [Required] public DateTime Created { get;