asp.net-mvc-5

Redirect user after authentication with OpenIdConnect in ASP.Net MVC

£可爱£侵袭症+ 提交于 2019-11-30 05:28:56
问题 I am using OpenIdConnect provider with Owin/Katana for authentication in my asp.net mvc application. OpenIdConnect Provide authenticates users against Active Directory. I wanted to do a simple authorization check once the user is authenticated and redirect the user to another view. app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions() { Authority = "url", Scope="scopes", ResponseType = "response", ClientId = "clientid", SignInAsAuthenticationType = "Cookies",

How to extend asp.net web api 2 user?

℡╲_俬逩灬. 提交于 2019-11-30 05:28:55
I'm building a Web API (2) project and use "individual account" authentication . I want to extend user with some details (like first name/last name, etc) (in model) obtain that info after login (on client side - my case windows phone) I've just started learning MVC and Web API so can anybody help me on this? Let me explain myself a little bit: I have create webapi project and selected as authentication method - "inidividual accounts" well I've added a model class called Person with 2 fields: FirstName and LastName. Well I've used fiddler to register a user called "johndoe" with a password.

Dependency Injection Structuremap ASP.NET Identity MVC 5

ぃ、小莉子 提交于 2019-11-30 05:07:48
I'm using the new ASP.NET MVC 5 Identity framework for authentication. I've traditionally used StructureMap for dependency injection, but I'm having problems wiring it up to work with the new AccountController. My AccountController constructors look like this: public AccountController() : this(new UserManager<OmpUser>(new UserStore<OmpUser>(new OmpDbContext()))) { } public AccountController(UserManager<OmpUser> userManager) { UserManager = userManager; } My StructureMap config looks like this: public static class IoC { public static IContainer Initialize() { ObjectFactory.Initialize(x => { x

How to assign a Role to a user in MVC5?

我们两清 提交于 2019-11-30 04:54:58
问题 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. 回答1: 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

MVC5 project template for Visual Studio 2012

北城余情 提交于 2019-11-30 04:54:42
I'd like to get started with ASP.NET MVC 5 using Visual Studio 2012. I've installed the " ASP.NET And Web Tools 2013 for Visual Studio 2012 , but this "only" gives me an "Empty ASP.NET MVC 5 Project" template. For MVC4 web projects, I can select different kinds of Web applications (like "Standard", "Internet", "Intranet" etc.). And I've seen screenshots with similar options for Visual Studio 2013. Are there any project templates (for VS2012) which allow me to do the same for MVC5 applications? It seems that "currently" there is only included the Empty Project template, and MS officially hasn't

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

我的未来我决定 提交于 2019-11-30 04:46:47
问题 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? 回答1: You

How do I setup ASP.NET Identity to use my own connection string?

走远了吗. 提交于 2019-11-30 04:41:57
I have an MVC5 app that's using EF. I would like to add ASP.NET Identity and I've noticed that the connection string for ASP.NET identity is using "DefaultConnection". What Do I need to do so that ASP.NET Identity tables are created in my already existing db (source=DILS-S1301;initial catalog=MVC5;) as specified in MVC5Entities and NOT DefaultConnection => (LocalDb)\v11.0 ?? thanks <connectionStrings> <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MySuperAwesomeMVCApp-20131105011429.mdf;Initial Catalog=aspnet

Rotativa PDF generation working locally but not on IIS 7

爱⌒轻易说出口 提交于 2019-11-30 04:15:58
I have an ASP.NET MVC 5 application. It has a simple form and when the user submits it, the form is stored in the cache and then another controller action is called, this action will return the model as a view as a PDF. I have no need to save it locally, just to show it in the browser so that the user can download it. There is no need for a database either, that is why I store the model in the cache. Locally, on Visual studio 2013, it works fine. But when I publish it to IIS 7 I get an Unhandled Execution Error . Here is the stack trace that I get back: Unhandled Execution Error Description:

Change OWIN Auth Middleware Per Request (Multi-tenant, oauth API keys per tenant)

匆匆过客 提交于 2019-11-30 03:58:30
I have a multi-tenant application. Each tenant can authenticate its users using OAUTH-2 with Facebook, Twitter, Google, etc. Each tenant has its own API keys for the aforementioned services. The typical way to setup the OWIN pipeline is to "use" auth providers in Startup but this sets the API keys at app start. I need to be able to change which keys are used with each oauth API for each request. app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, Provider = cookieAuthProvider, CookieName = "VarsityAuth", }); app

MVC 5 How to use an object in rdlc report

蓝咒 提交于 2019-11-30 03:41:17
问题 this is my first question here. I'm using VS Community 2015 and a MVC 5 project with Entity Framework 6. I use code first migration for data modeling. I allready have reports using a view for each one. Each view uses a C# model for show report as a HTML5 web page. Now I have to send the output to pdf, word, excel... For that I'll use RDLC but I don't know how set the object model as a dataset. The idea is send the same object that allready use the view for build the report. The data for the