asp.net-mvc-5

how authorization asp(mvc) project from controller?

廉价感情. 提交于 2019-12-02 16:38:32
问题 I'm new in asp and I created a login page for my web project but and I set authentication but I can not set authorization for my project! I saw many links like this Authentication and Authorization in ASP.NET Web API but couldn't implementation those on my own project, I don't know where I must to start?! thank you for your help! this is my controller: public class AuthenticationController : Controller { private modelLayOut mLO = new modelLayOut(); public bool existBool = false; // GET:

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

瘦欲@ 提交于 2019-12-02 16:25:56
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 capability implemented as usual Asp.net MVC full page reload controller/views and then redirect back to my

Custom Membership with Microsoft.AspNet.Identity - CreateLocalUser fails

北城余情 提交于 2019-12-02 15:37:41
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 Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.EntityFramework; using System; using System

Security Exception for default MVC 5 application

谁都会走 提交于 2019-12-02 15:21:37
问题 I got security exception when deploying the default MVC 5 app generated with VS 2013 to my hosting account. Is there any quick solution for this problem? Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of

Custom Identity using MVC5 and OWIN

故事扮演 提交于 2019-12-02 15:15:54
I trying to add custom properties to the ApplicationUser for a web site using MVC5 and OWIN authentication. I've read https://stackoverflow.com/a/10524305/264607 and I like how it integrates with the base controller for easy access to the new properties. My issue is that when I set the HTTPContext.Current.User property to my new IPrincipal I get a null reference error: [NullReferenceException: Object reference not set to an instance of an object.] System.Web.Security.UrlAuthorizationModule.OnEnter(Object source, EventArgs eventArgs) +127 System.Web.SyncEventExecutionStep.System.Web

Identity 2.0 with custom tables

牧云@^-^@ 提交于 2019-12-02 14:53:50
I'm new to ASP.NET identity and am still trying to get my head around how it all works. Unfortunately I've found many of the tutorials I've tried are for Identity 1.0, whereas I'm attempting to work with Identity 2.0. The biggest problem I am facing is something I thought would be simple, but has turned out not to be. What I'm trying to do is use an existing database with an existing user table. Currently all I can seem to do is get Identity to create it's own tables to store user data. I don't want to use Entity Framework, but I've had great difficulty separating Entity Framework from

Design First Datetime Key. My scaffolded controller is finding MM/dd/yyyy instead of dd/MM/yyyy

[亡魂溺海] 提交于 2019-12-02 14:53:09
问题 Would like some help please: Design First (Access Conversion) Composite Key is CalendarDate and Round. From Index.cshtml <tbody> @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem => item.CalendarDate) </td> <td> @Html.DisplayFor(modelItem => item.Round) </td> <td> @Html.DisplayFor(modelItem => item.SundayComp) </td> <td> @Html.ActionLink("Edit", "Edit", new { CalendarDate = item.CalendarDate.ToString("dd/MM/yyyy"), Round = item.Round }) | @Html.ActionLink("Delete", "Delete",

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

只谈情不闲聊 提交于 2019-12-02 14:38:31
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); } Developer It is here ASP.NET Identity reset password UserManager<IdentityUser> userManager = new UserManager<IdentityUser>(new UserStore<IdentityUser>()); userManager.RemovePassword(userId); userManager.AddPassword(userId, newPassword); I suppose this is newer but there

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

邮差的信 提交于 2019-12-02 14:06:36
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 controller that contains action methods like public async Task<ActionResult> ExternalLoginCallback

ASP.NET MVC Routes: How do I omit “index” from a URL

▼魔方 西西 提交于 2019-12-02 13:52:07
问题 I have a controller called "StuffController" with a parameterless Index action. I want this action to be called from a URL in the form mysite.com/stuff My controller is defined as public class StuffController : BaseController { public ActionResult Index() { // Return list of Stuff } } I added a custom route so the routes are defined like this: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // Custom route to show index routes