asp.net-mvc-5

Does Identity Owin require LazyLoading?

半世苍凉 提交于 2019-12-01 16:04:39
tl;dr: Identity seems to require that LazyLoading NOT be disabled; is this true, and what is the cleanest workaround? I did some basic A-B testing on a simple C# ASP.NET 4.5.1 MVC-5 web application using EntityFramework 6.0.2, Identity EntityFramework 1.0.0, and Identity Owin 1.0.0 and it appears that Owin requires that lazy loading is NOT disabled in the ApplicationContext constructor. To replicate the issue just make a quick MVC app using Visual Studio 2013, use the MVC template, leave everything at the defaults except uncomment the line: 'app.UseGoogleAuthentication();' in App_Start/Startup

How localize ErrorMessage in DataAnnotation?

孤者浪人 提交于 2019-12-01 15:57:38
问题 Using MVC 5 I need to localize an ErrorMessage for a DataAnnotation attributes. I receive the following error ERROR An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type In model [Compare("Password", ErrorMessage = Resources.Account_Register_ConfirmPasswordErrorMessage)] public string ConfirmPassword { get; set; } Any idea how to fix it? 回答1: You need to use ErrorMessageResourceName and ErrorMessageResourceType

Does Identity Owin require LazyLoading?

*爱你&永不变心* 提交于 2019-12-01 15:57:29
问题 tl;dr: Identity seems to require that LazyLoading NOT be disabled; is this true, and what is the cleanest workaround? I did some basic A-B testing on a simple C# ASP.NET 4.5.1 MVC-5 web application using EntityFramework 6.0.2, Identity EntityFramework 1.0.0, and Identity Owin 1.0.0 and it appears that Owin requires that lazy loading is NOT disabled in the ApplicationContext constructor. To replicate the issue just make a quick MVC app using Visual Studio 2013, use the MVC template, leave

Automapper exception: “Missing type map configuration or unsupported mapping.”

和自甴很熟 提交于 2019-12-01 15:55:46
I am trying to use Ninject in an ASP.NET MVC 5 application that uses AutoMapper for mapping the Model to the View Model and vice versa. Unfortunately I get an error message that states that the type map configuration is missing. I created a Ninject dependency resolver: namespace MyNamespace.Infrastructure { public class NinjectDependencyResolver: IDependencyResolver { private IKernel kernel; public NinjectDependencyResolver(IKernel kernelParam) { kernel = kernelParam; AddBindings(); } public object GetService(Type serviceType) { return kernel.TryGet(serviceType); } public IEnumerable<object>

Automapper exception: “Missing type map configuration or unsupported mapping.”

隐身守侯 提交于 2019-12-01 15:33:05
问题 I am trying to use Ninject in an ASP.NET MVC 5 application that uses AutoMapper for mapping the Model to the View Model and vice versa. Unfortunately I get an error message that states that the type map configuration is missing. I created a Ninject dependency resolver: namespace MyNamespace.Infrastructure { public class NinjectDependencyResolver: IDependencyResolver { private IKernel kernel; public NinjectDependencyResolver(IKernel kernelParam) { kernel = kernelParam; AddBindings(); } public

GitHub Commit Error: Permission denied fatal: Unable to process path ~/App_Data/aspnet-MyProject.mdf

时光怂恿深爱的人放手 提交于 2019-12-01 15:32:54
问题 I am attempting to commit an update to my ASP.Net MVC project using GitHub integration in Microsoft Visual Studio 2017. I am working on Code-First Migrations. After my previous successful commit, I performed the following commands on the Package Manager Console in Visual Studio: PM> Enable-Migrations -ContextType ApplicationDbContext PM> Add-Migration AccountNumberChanges PM> Update-Database -Verbose Once this was done, I tried perform a commit, but I was getting the following error: Git

Feature 'interpolated strings' is not available in C# 5. Please use language version 6 or greater.

懵懂的女人 提交于 2019-12-01 15:19:43
The following line does not compile when I put in a Razor View. var extPropLookupNameCompania = $"extension_{SettingsHelper.ClientId.Replace("-", "")}_{"Compania"}"; However in the controller the same line works perfectly fine. Why I cant user string interpolation on the razor views? or Maybe I need to configure something? If you are experiencing this error in a .NET Framework 4.5.1 project, upgrading to 4.5.2 solves the problem. You have to encapsulate it with braces like this: EDIT: I updated because there was a missing curly. var extPropLookupNameCompania = $("{extension_{SettingsHelper

Using MVC 5's identity, can't get user name right after logging in

核能气质少年 提交于 2019-12-01 15:00:47
问题 I'm trying to use the MVC 5's identity solution, but got stuck on something that should be very simple: I want the login method on the AccountController to get the loged user's name right after validating the model (and I don't want to use it from the model!). Here's a piece of my code: var result = await SignInManager.PasswordSignInAsync(model.Login, model.Password, false, shouldLockout: false); string NomeUsuario = ""; if (result == SignInStatus.Success) { NomeUsuario = User.Identity.Name;

How i do Required If validation by function in MVC5

懵懂的女人 提交于 2019-12-01 14:51:56
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; } 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("NotifyMeByEmail", ErrorMessage = "Please enter you email address")] public string EmailAddress { get; set; } Then

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

核能气质少年 提交于 2019-12-01 14:32:40
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 { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{