asp.net-mvc-5

Extra column/field on IdentityUserRoles table using Identity 2 and Entity Framework 6

柔情痞子 提交于 2019-12-24 03:08:59
问题 I'm using a custom implementation of the IdentityUser class in my project. The problem is that Entity Framework adds an extra column in the table IdentityUserRoles , mapping the child class Id as a constraint. I know that EF is probably getting confused on figuring how to map the relationship with this new class, I just don't know why and how to solve it. I've been searching the web about this EF behavior, but couldn't find a solution yet. Here are some screenshots that summarize the problem:

MVC 5 IdentityDbContext and DbContext transactions

寵の児 提交于 2019-12-24 03:00:24
问题 I work on a MVC 5 project with EF6.1. As a beginner, I try to keep the code generated by the MVC 5 template in order to use the default authentification system with AccountController. However, I had to add some classes, like "User.cs" as below, so I'm using Entity Framework Data Model. public partial class User { public User() { this.Logs= new HashSet<Log>(); } public int IdUser { get; set; } public string AspNetUsersId { get; set; } //References to AspNetUsers.Id public string Title { get;

Blank custom 404 page after deploying to IIS 7.5

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 02:55:18
问题 Incorrect urls like http://localhost:54321/foo/bar and errors like HttpNotFound() are handled in my localhost without problems. After deploying to IIS 7.5, it return a blank page on both of the above scenarios. I've seen someone else had this problem Here(It was the comment from Moulde with several upvotes). The code: Web.Config <system.web> <customErrors mode="Off" redirectMode="ResponseRedirect"> <error statusCode="404" redirect="~/Error/NotFound"/> </customErrors> </system.web> <httpErrors

Date inconsistency across browsers - MVC 5 date from model

十年热恋 提交于 2019-12-24 02:44:15
问题 I have this in a view model: [Required] [Display(Name = "Date of birth")] [DataType(DataType.Date), DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)] public DateTime DateOfBirth { get; set; } And on the form: <div class="form-group"> @Html.LabelFor(model => model.DateOfBirth, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.DateOfBirth, new { htmlAttributes = new { @class = "form-control" } })

Seeking functionality on mp4 video in html5 is not working

做~自己de王妃 提交于 2019-12-24 02:39:12
问题 I have an asp.net mvc 5 site and on the home page I need to display a video in mp4 format. Everything works nice except the seeking functionality. I spent several hours looking for a solution but I didn't had any luck. The html element: <video id="appVideo" controls style="width: 100%; height: 100%"> <source src="@Url.Action("HomePageVideo", "Home")" type="video/mp4" /> </video> The controller method for retrieving the video: [HttpGet] [AllowAnonymous] public ActionResult HomePageVideo() {

ReactJS.Net on MVC5 fails to resolve dependency

徘徊边缘 提交于 2019-12-24 02:23:41
问题 I'm trying to set up an ASP.Net MV5 application to work with ReactJS.Net, including server side rendering and bundling. Unfortunately, it fails with this exception: An exception of type 'React.TinyIoC.TinyIoCResolutionException' occurred in React.dll but was not handled in user code Additional information: Unable to resolve type: React.ReactEnvironment This exception occurs on this line: @Scripts.Render("~/bundles/ui-components") This line is taken my _layouts.cshtml file. How should I solve

ASP.NET MVC Html.Editor pass model to Editor Template

北城余情 提交于 2019-12-24 02:16:06
问题 I have an Editor Template called "Address.cshtml" that has a model defined as: @model Acme.Models.Address In a View I want call the Editor Template and pass a local variable of the same type, and define the name it will use for the variables, I've tried a number of things including: @Html.Editor("address", "Address", new { Model = address }) How do I pass the model? Note, I cannot use @Html.EditorFor() because the view uses a different model. 回答1: The only purpose of EditorFor is to work with

MVC: POST controller method get empty Dictionary

白昼怎懂夜的黑 提交于 2019-12-24 02:06:38
问题 My GET method of controller construct and fill Model, which including Dictionary<int, MyClass> , and transmit that to View. But after, POST controller method get not null model with empty Dictionary. Model: public class CheckBoxItem { public string Name { get; set; } public double Data { get; set; } public bool Selected { get; set; } } public class CreateNewEventModel { [Required(ErrorMessage = "Error text")] [Display(Name = "Header name")] public string EventName { get; set; } public

Inject Entity Framework DbContext using Ninject in ASP.NET MVC5

≡放荡痞女 提交于 2019-12-24 01:24:32
问题 I have just landed in dependency injection world. I have the following custom DbContext- public partial class SkyTrackerContext: DbContext { public SkyTrackerContext(): base() { Database.SetInitializer(new SkyTrackerDBInitializer()); } } Would like inject SkyTrackerContext in this base controller- public abstract class BaseController : Controller { public BaseController() {} [Inject] public SkyTrackerContext MyDbContext { get; set; } } Sample usage- public class LoginController :

Bootstrap Form Horizontal Alignment Errors

穿精又带淫゛_ 提交于 2019-12-24 01:08:39
问题 My textboxes aren't aligning with my form properly at all. I'm using Bootstrap within ASP.NET MVC 4. As you can see I'm using the form-horizontal div but im not sure why my elements are appearing all out of line. How do I get the elements to align with the labels? <div class="form-horizontal"> @Html.ValidationSummary(true) <div class="form-group"> @Html.Label("Please enter the Inventory No", new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.TextBoxFor(model => model.Log