asp.net-mvc-5

How do I properly register AutoFac in a basic MVC5.1 website?

岁酱吖の 提交于 2019-12-03 03:08:11
问题 AutoFac has recently been updated for MVC 5.1 but at the time of writing I find that the documentation is lacking (especially for a simple example). I would like to inject dependencies into MVC Controllers and register my own implementations for e.g. e-mail (actual sending vs print to output window) as a basic example. I'm do not know if I am missing a good resource for this and I am slight concerned that because it uses the OWIN specification that the implementation may differ for MVC5.1

Recommended authentication UX in AngularJS SPA with own and external (Google, FB…) profiles

▼魔方 西西 提交于 2019-12-03 02:52:01
问题 I'm developing an Asp.net MVC + Web API + AngularJS SPA. I would like to have several types of registration/authentication: own profile provider external providers ie Google, FB etc. Possible scenarios As I'm having an SPA it would be best if I could keep my user on my page while external (or internal for that matter) would be taking place. I'd display a modal layer with particular content loaded (maybe even inside an iframe ). Can this be done? Online examples? Have login/registration

How to reset password with UserManager of ASP.NET MVC 5

让人想犯罪 __ 提交于 2019-12-03 02:44:09
问题 I am wondering if there is a way to reset password with UserManager of ASP.NET MVC 5 I tried this with user that already has a password but no success. Any clue? IdentityResult result = UserManager.AddPassword(forgotPasswordEvent.UserId.ToString(), model.ConfirmPassword); if (result.Succeeded) { // } else { AddErrors(result); } 回答1: It is here ASP.NET Identity reset password UserManager<IdentityUser> userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>()); userManager

Display error message on the view from controller asp.net mvc 5

不打扰是莪最后的温柔 提交于 2019-12-03 02:22:11
I am new to web development and trying to learn ASP.Net MVC 5. I am looking for one record in database if the record is not found then I want to display an error message to the user. Below is my attempt: Controller [HttpGet] public ActionResult Search() { return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult Search(ForgotPasswordMV viewModel) { if (Temp.Check(viewModel.Email)) return RedirectToAction("VerifyToken", new { query = viewModel.Email }); else { ViewBag.ErrorMessage = "Email not found or matched"; return View(); } } View: <p>@ViewBag.ErrorMessage</p> ViewModel

Custom Membership with Microsoft.AspNet.Identity - CreateLocalUser fails

限于喜欢 提交于 2019-12-03 02:02:08
问题 I've been trying to implement a custom version of the new Identity features in ASP.NET 4.5 (Microsoft.AspNet.Identity), using Visual Studio 2013. After many hours of playing around with this, I've simplified my code in an effort to get it running without errors. I've listed my code below. When doing a Local Registration, the database tables are created, but the CreateLocalUser method fails. I'm hoping that someone can help me identify the changes needed. Models/MembershipModel.cs using

Nested layouts for MVC5

余生长醉 提交于 2019-12-03 01:59:55
I've seen a few posts on this topic: Razor Nested Layouts with Cascading Sections MVC 3 - Nested layouts - sections don't render in Areas And it always seems to be problematic. However they are both pretty old so wondering if things have changed. Basically I have a master layout, and 3 different body templates based on what kind of page it is. For examples sake: _Layout.cshtml <html lang="en"> <head> </head> <body style="padding: 50px 0;"> <header class="navbar navbar-default navbar-fixed-top" role="banner"> @Html.Partial("_MenuPartial") </header> <ol class="breadcrumbs"> @RenderSection(

Resolving IOwinContext in MVC5 application using Autofac

偶尔善良 提交于 2019-12-03 01:53:45
I have trouble using MembershipReboot with the new ASP MVC5 template and Autofac . I have used the default MVC5 template to set up the site and then tried to wire up the MembershipReboot framework as a replacement for the ASP Identity framework that ships with the template. This issue I am having is trying to resolve an IOwinContext from the Autofac container. Here is my wiring in the Startup class (cut down to basics). This is the wiring used in the samples for the MembershipReboot Owin application (except there he uses Nancy). public partial class Startup { public void Configuration

How to integrate Autofac with WepApi 2 and Owin?

非 Y 不嫁゛ 提交于 2019-12-03 01:22:11
I am using this package to integrate Autofac with my WebApi Owin application: https://www.nuget.org/packages/Autofac.WebApi2.Owin And following this post: http://alexmg.com/owin-support-for-the-web-api-2-and-mvc-5-integrations-in-autofac/ My code in Startup.cs looks like this: var config = new HttpConfiguration(); IContainer container = EngineContext.InitializeEngine(); var dependencyResolver = new AutofacWebApiDependencyResolver(container); config.DependencyResolver = dependencyResolver; app.UseAutofacMiddleware(container); app.UseAutofacWebApi(config); WebApiConfig.Register(config); app

SignInManager,what it is and how,when to use?

喜欢而已 提交于 2019-12-03 00:29:38
问题 I am exploring SignInManager class. But the information given on MSDN is very useless. It only tells what are the methods and properties provided. What I am looking for is, 1) What is SignInManager? 2) How to use it? 3) And I have my own database that contains credentials related info(username and passwords) How can I use SignInmanager and how to use it so my custom database is used for authenticating users? I am using asp.net MVC 5 and Visual Studio 2015. In my sample project I have accounts

How to use Roles in user identity in MVC 5

二次信任 提交于 2019-12-03 00:16:09
I want to use asp.net useridentity in mvc 5, I do these steps: 1) create a mvc project. 2) create my own database and change the connectionstring in web.config form: to: 3) I run the project and create a new user to add related table to my database. 4) I wanted to add a role to a user after registration a user like this code in accountControler: public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { UserName = model.Email, Email = model.Email }; IdentityResult result = await UserManager.CreateAsync(user, model.Password);