asp.net-mvc-5

How can I use Bootstrap button addons in my MVC view

自作多情 提交于 2019-12-04 04:53:04
I'm having difficulty getting Bootstrap's button addons to work in my MVC view. I'm using the latest NuGet version of ASP.NET MVC (5.1 rc1) and Bootstrap (3.03). I have the following in my view (now that I've pared it back to just hand-coded HTML rather than using Html.EditorFor() , in an attempt to getting it to work): @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> @Html.ValidationSummary(true) <div class="row"> <div class="col-lg-6"> <div class="input-group"> <input type="text" class="form-control" /> <span class="input-group-btn"> <button class="btn btn

MVC 5 ASP.NET Identity 2: Capture user's preference for “remember me” in ExternalLogin

夙愿已清 提交于 2019-12-04 04:43:57
问题 I am using the Identity 2.0 Sample. I get that by setting isPersistent to true in ExternalLoginCallback action method, the browser will automatically log the user in the next time (within limits) they visit using the same browser. I know that if the user's "remember me" preference was captured and passed to the ExternalLogin action method that it could be put into returnUrl and accessed in ExternalLoginCallback. But how do I get their preference to the ExternalLogin action method? I don't get

Authorize attribute not working MVC 5

孤者浪人 提交于 2019-12-04 03:19:18
问题 I have separated the Models into Specific project After that MVC default [Authorize] attribute not working in my application When i try to login the application it is not login the application nor it is redirecting to the specific page 回答1: Do you have something like this <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880" /> </authentication> in your web.config? 回答2: Check if you have removed the forms authorization module. Some of the new templates remove forms

How to delete users that were created with UserManager.CreateAsync

走远了吗. 提交于 2019-12-04 03:16:02
Using asp.net mvc5, my user management systems seems to work. I can login with google or with name/password.. but now I am working on a user management interface in which I need to be able to delete existing users. And this is starting to expose to me just how confusing the user management system is. There's so many different ways to deal with users.. and some of them don't work. Most everywhere I read, it is talking about using the Membership.DeleteUser(). But that isn't working... The users were created with. var user = new ApplicationUser() { UserName = model.UserName, Email = model.Email,

Using of HandleErrorAttribute in ASP.NET MVC application

淺唱寂寞╮ 提交于 2019-12-04 03:09:21
I have a question about the best way of using HandleErrorAttribute in my MVC 5 application. As we know, we can add this attribute to global filters like that: filters.Add(new HandleErrorAttribute{View = "Error"}); This involves the app to show the 'Error' view every time when an unhandled exception is thrown in any level of app. But, if I have some logic in another global authorize or action filter, that produces some exception, then when the exception is thrown for first time, the app tries to redirect to the Error View, again other filters begin executing and produce the same exception again

does “BundleTable.EnableOptimizations = true;” automatically minify the files or it will just select the .min if it is available

笑着哭i 提交于 2019-12-04 02:42:30
I need to know if specifying "BundleTable.EnableOptimizations = true;" will automatically minify the files (js & Css)or it will just select the .min if it is available ? One has nothing to do with the other. BundleTable.EnableOptimizations exists merely to provide a way to force bundling in development, where it's disabled by default. In production, it's enabled by default, and unnecessary to specify anything for EnableOptimizations . Either way, though, it only determines whether bundling will happen or not, not how it will occur or what will happen as a result. That said, the standard

UserManager Error - A second operation started on this context before a previous asynchronous operation completed

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 02:34:33
I am facing this issue with my asp.net MVC5 web application, using Identity v2.0.0.0, EF 6, Castle Windsor IOC Container, Microsoft SQL Server 2005 I am trying to get the current logged in User by using UserManagerExtensions,FindById() method but it is throwing an error "System.NotSupportedException : A second operation started on this context before a previous asynchronous operation completed. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context. Any instance members are not guaranteed to be thread safe" What I understood from the

GlobalConfiguration does not contain a definition for Configure

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 02:14:05
I'm attempting to create an ASP.NET MVC site that uses Database First Entity Framework. I'm using creating a new MVC 5 site in Visual Studio Professional 2013 Update 3 , then adding an ADO.NET Entity Data Model from which I choose EF Designer from database . After that, I create a connection string, select the tables to generate the framework, and all is well. However when I compile it, I receive this error 'MyModel.GlobalConfiguration' does not contain a definition for 'Configure' This is in Global.asax.cs and errors here protected void Application_Start() { AreaRegistration.RegisterAllAreas(

ASP.NET Identity - Forcing a re-login with security stamp

前提是你 提交于 2019-12-04 00:31:53
问题 So from What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface? we learn that ASP.NET Identity has a security stamp feature that is used to invalidate a users login cookie, and force them to re-login. In my MVC app, it is possible for admins to archive users. When arched, they should immediately be logged out and forced to log in again (which would then reject them since they're archived). How can I do this? I understand that the security stamp is the key. The default setup looks

How to use Exception filters in MVC 5

一笑奈何 提交于 2019-12-04 00:11:07
问题 How i can implement Exception Filters in MVC5. I want to throw the exception to NLog and redirect the page to a default error page which displays "Something is gone wrong" I have a Filter class as follows using System; using System.Diagnostics; using System.Security.Policy; using System.Web.Mvc; using System.Web.Mvc.Filters; using System.Web.Routing; using System.Web.UI.WebControls; using Delivros.UI.Controllers; using Delivros.UI.Areas.User.ViewModel; using System.Web; namespace Delivros.UI