asp.net-mvc-5

Store does not implement IUserLockoutStore<TUser>

Deadly 提交于 2019-11-30 22:49:45
问题 I'm trying to implement own DAL for asp.net Identity 2.0 with functionality that I need. I don't need Account Lockout functionality. But When I try to call var result = await SignInManager.PasswordSignInAsync(model.Login, model.Password, model.RememberMe, shouldLockout: false); I get System.NotSupportedException:Store does not implement IUserLockoutStore<TUser>. So why should I need to implement IUserLockoutStore if I dont need it? 回答1: See this answer: When implementing your own IUserStore,

ListBoxFor MultiSelectList does not select values

人走茶凉 提交于 2019-11-30 22:14:20
I'm incredibly confused, because this seems like it should be simple but I can't get my ListBox to be populated with selected values. I've looked at several other answers and I can't figure out what I'm doing wrong. This is my model: public class ItemViewModel { public IEnumerable<Item> AllItems { get; set; } public IEnumerable<Item> SelectedItems { get; set; } } public class Item { public string Id { get; set; } public string Name { get; set; } } This is my controller action: public ActionResult ListBoxTest() { var viewModel = new ItemViewModel() { AllItems = new List<Item>() { new Item() {

How to structure a new ASP MVC app?

北城以北 提交于 2019-11-30 22:04:18
I need to start a new mvc project and as always I have issues about asp identity, never know where to put it! I plan to organize solution like this: ProjectWebUI - mvc app with asp identity framework (made from internet template with authentication) ProjectDataAccessLayer - with repository classes that use dapper as database access technology ProjectWebAPI - web service But I have a little confusion and before start coding I need advice from someone more experienced (as until now all my projects were just one project with data access in it): Is it good idea to have asp identity inside WebUI

How to remember the login in MVC5 when an external provider is used

风流意气都作罢 提交于 2019-11-30 20:41:44
In our MVC5-application with OWIN, we use additional to the local accounts also external logins (google). When the user logs in with its local account, he can activate the option to remember him, so he has not to log-in every time newly. When he logs in with his Google-account, he every time must click newly on the external login-button for google. Is there a built-in option to activate the “remember me”-option also for external logins? Or is there a secure way to add this feature? You just need to set IsPersistent to true to accomplish this when you sign in the user identity (you would want

How to assign a Role to a user in MVC5?

回眸只為那壹抹淺笑 提交于 2019-11-30 20:37:12
In MVC4 I was using the code Roles.AddUserToRole(User.Identity.Name, "Approved"); Is there any other way of doing the same(adding user to role "Approved") in MVC5 Identity Model? EDIT: I meant to ask is this the right way of adding a user to a role? Because in a lot of examples they do not use this code. You can call AddToRole or AddToRoleAsync as an instance method on any object of type UserManager<TUser> to achieve it in MVC 5, like below: var _context = new ApplicationDbContext(); var UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(_context)); UserManager

Calling JavaScript function in MVC 5 Razor view

寵の児 提交于 2019-11-30 20:03:19
I have seen in another post that you can call a JavaScript function in your razor code like so: @:FunctionName() For me though this only outputs the actual words FunctionName() Here is my view: @model PriceCompare.Models.QuoteModel @{ ViewBag.Title = "Quote"; } <h2>Quote</h2> @if (@Model.clarify == true) { // do drop down loic @:ShowClarify(); } else { // fill quote @:ShowQuote(); } <div class="clarify"> You can see the clarify div </div> <div class="quote"> You can see the quote div </div> @section head { <script type="text/javascript"> $(document).ready( function ShowQuote() { $(".quote")

Data Annotations / Validation not working for partial views

橙三吉。 提交于 2019-11-30 19:57:18
问题 I have some partial views loaded at runtime, based on user input. $("#Categories").change(function () { $.ajax({ url: "/Product/Create" + $("#Categories option:selected").text().replace(/\s+/, ""), type: "Get" }).done(function (partialViewResult) { $("#partialDiv").html(partialViewResult); }); }); The POCO's that are used in the view model are decorated with data annotations, but they are not triggered. The partial views each contain a form (Html.BeginForm()). I guess I'm doing something

Social Login of facebook not working in ASP.Net MVC 5 project

丶灬走出姿态 提交于 2019-11-30 19:54:18
问题 I am going through a tutorial to implement facebook social log in my sample web site. Below are the steps I did. Pointed my localhost application to https and allowed fake SSL in VS. Created a web app in facebook developer web site and noted down the secret key and id. Added my application localhost URL in the URL section of the dashboard in facebook I added key and id in the starup.Auth.cs file in my ASP.Net MVC-5 project . Behavour: Now when I run my application from local host (https) and

Identity 2.1 - UserId not found but was working before

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 19:20:42
This code worked before numerous times but after adding in a couple new properties for a user in Identity 2.1 it has ceased to work suddenly. I am getting a UserId not found error, despite there being a value visible in the debugger for UserId. Anyone have an idea on why this has suddenly happened? It's very frustrating to see the least. Here's code: (Controller) // POST: /Account/Register [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Register(RegisterViewModel model) { model.BackgroundOnFile = false; if (ModelState.IsValid) { var userDetails = new

Non-Azure Deployment through VS 2015 RC

偶尔善良 提交于 2019-11-30 19:12:48
I'm trying out ASP.NET 5 and all its new features on VS 2015 Enterprise RC. To ensure smooth end-to-end deployment, I then try to deploy the application to a non-Azure private server through VS Publish feature. However, I'm missing out a very important feature: the ability to publish to a non-Azure server. In earlier versions of Visual Studio (I'm using VS 2013), the Custom options is there. I've tried tinkering with the Project Properties but nothing on how to deploy my ASP.NET 5 app to a custom server. Any ideas? It's doable (after all, publishing to Azure websites also uses WebDeploy