asp.net-mvc-5

How to Update Employee and Identity User with one to one/zero relation

≡放荡痞女 提交于 2019-12-04 07:11:01
问题 I am trying to update employee record and want to update identity user too. If i update Identity User first separately For Example: UserManager.Update(user); Context.Entry(employee).State = System.Data.Entity.EntityState.Modified; Context.SaveChanges(); and then update the employee. maybe it is possible identity user updates with success but employee update process gets an error. so IdentityUser is updated now but the employee is not. how to handle this situation. please guide. public class

EF6 - Using the await keyword with the Where() clause

£可爱£侵袭症+ 提交于 2019-12-04 06:47:00
I am coding a MVC 5 internet application with entity framework 6 and have a question in regards to using the await keyword when using the .Where() clause. Here is my code that works: public async Task<Account> GetAccount(string userName) { if (Session[userName] == null) { Account account = db.accounts.Where(a => a.userName.Equals(userName)).FirstOrDefault(); if (account == null) { //log out return null; } Session[userName] = account; } return Session[userName] as Account; } I am wanting to use the await keyword when retrieving the Account object as follows: Account account = await db.accounts

jQuery validate plugin is not working in MVC form

早过忘川 提交于 2019-12-04 06:43:31
问题 I have a MVC form like this <head> <script src="~/Scripts/jquery-1.8.3.js"></script> <script src="~/Scripts/jquery.validate.js"></script> </head> <body> <form action="" method="get" id="login"> <input id="email" class="text required email" type="text"> <input type="submit" value="Login..."> </form> <script> $(function () { $("#login").validate() }); </script> </body> but for some reason when i click on the submit button the jquery validate is not working and i get an error like this Uncaught

How to move MVC 5 IdentityModels.cs into a separate assembly

妖精的绣舞 提交于 2019-12-04 06:41:00
I wonder if someone ran into the issue that I am having with trying to move ApplicationUser into Models project (where all other models reside including the ones related to Users table). My test MVC 5 solution consists of a web project and two class libraries: one for data access layer (DAL) and the other for Models. I references AspNet.Identity.EntityFramework in all three projects. In my DAL class I implement Repository pattern and a UnitOfWork. UnitOfWork extends IdentityDbContext<ApplicationUser> . ApplicationUser : IdentityUser is in Models class library. In my web project UnitOfWork is

DynamoDB consistent reads for Global Secondary Index

江枫思渺然 提交于 2019-12-04 06:15:23
Why cant I get consistent reads for global-secondary-indexes? I have the following setup: The table: tblUsers (id as hash) Global Secondary Index: tblUsersEmailIndex (email as hash, id as attribute) Global Secondary Index: tblUsersUsernameIndex (username as hash, id as attribute) I query the indexes to check if a given email or username is present, so I dont create a duplicate user. Now, the problem is I cant do consistent reads for queries on the indexes. But why not? This is one of the few occasions I actually need up-to-date data. According to AWS documentation: Queries on global secondary

Angular $locationProvider with ASP.NET MVC routing

让人想犯罪 __ 提交于 2019-12-04 06:09:56
问题 I'm handling routing using ASP.NET MVC (using RouteCollection class). But my front end is written in angular and at some places I want to change url using Angular's $location and I want it to support HTML5, so I added this line to my module.config : $locationProvider.html5Mode(true); But since then it seems that my routing has been handled by Angular. For example my SPA is on mysite.com/user and there I want to change url using Angular's $location (so when for example users click tab url

Newtonsoft.Json.dll conflicts between Visual Studio 12.0 Blend and MVC 5 web project VS 2013

南楼画角 提交于 2019-12-04 05:56:46
I have a asp.net mvc 5 project in VS2013, I updated the nuget packages of everything to latest then I run into this error Error 2 The type 'Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver' exists in both 'c:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll' and '{path to my project}\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll' Does anyone else run into this. I got that error because I had an additional <ItemGroup> <Reference Include="Newtonsoft.Json"> <HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll<

C# MVC: Multi step form implementation

岁酱吖の 提交于 2019-12-04 05:51:58
问题 We are building MVC multi-step form that will have 4 steps:- Contact-details, Car-details, Car-images, Car-condition. At each step, we ask few car related details from the user like this: We have to save each step information to the database and we have made separate MVC controller for each step, for example: [HttpGet] [Route("contact-details/")] public ActionResult ContactDetails() { return View("~/Views/ContactDetails.cshtml"); } [HttpPost] [Route("contact-details/")] public ActionResult

The type or namespace name 'Models' does not exist in the namespace 'PartyInvites'

随声附和 提交于 2019-12-04 05:22:40
问题 Using VS2013 Pro, TFS 2013 Express I'm currently doing a tutorial from the book asp.net mvc 5 and everything was fine. yesterday I installed TFS 2013 Express onto my local machine, copied the project over to the TFS folder and added the project to source control. Since doing that I'm now getting errors like the subject. In this case the controller simply has a using: using System.Web; using System.Web.Mvc; using PartyInvites.**Models**; namespace PartyInvites.Controllers { public class

MVC HttpRequestValidationException exception

ぐ巨炮叔叔 提交于 2019-12-04 05:07:18
问题 I am coding a MVC 5 internet application and have a question in regards to the HttpRequestValidationException exception. My previous code in my controller is as follows: protected override void OnException(ExceptionContext filterContext) { // Make use of the exception later this.Session["ErrorException"] = filterContext.Exception; if (filterContext.Exception is HttpRequestValidationException) { TempData["UITitle"] = "Validation"; TempData["UIHeading"] = customErrorType; TempData["UIMessage"]