How do I ignore the Identity Framework magic and just use the OWIN auth middleware to get the claims I seek?

Use the following code to setup OWIN security middlewares: app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = “Application”, AuthenticationMode = AuthenticationMode.Passive, LoginPath = new PathString(“/Login”), LogoutPath = new PathString(“/Logout”), }); app.SetDefaultSignInAsAuthenticationType(“External”); app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = “External”, AuthenticationMode = AuthenticationMode.Passive, CookieName = CookieAuthenticationDefaults.CookiePrefix + “External”, ExpireTimeSpan = TimeSpan.FromMinutes(5), }); app.UseGoogleAuthentication(); The code above sets up application cookie, external …

Read more

Creating reusable HTML view components using Razor in ASP.NET MVC

There are two ways to achieve the required functionality. 1. @helper Create @helper which accepts whatever parameters you need plus a function (single object parameter, returns object): @helper DefaultPanel(string panelTitle, Func<object, object> content) { <div class=”panel”> <div class=”panel-logo”> <img src=”https://stackoverflow.com/logo.png” /> </div> <div class=”panel-inner”> <p class=”panel-title”>@panelTitle</p> <div class=”panel-content”> @content(null) </div> </div> </div> } Usage: @DefaultPanel(“title”, …

Read more

ASP.NET MVC 2.0 JsonRequestBehavior Global Setting

This, like other MVC-specific settings, is not settable via Web.config. But you have two options: Override the Controller.Json(object, string, Encoding) overload to call Json(object, string, Encoding, JsonRequestBehavior), passing JsonRequestBehavior.AllowGet as the last argument. If you want this to apply to all controllers, then do this inside an abstract base controller class, then have all your …

Read more

Can I use Entity Framework 6 (not core) in .net core?

Update You can now use EF 6.3 with .NET Core 3.0: https://devblogs.microsoft.com/dotnet/announcing-ef-core-3-0-and-ef-6-3-general-availability/#what-s-new-in-ef-6-3 Below is an excerpt. However, EF Core has come a long way these days and it’s worth giving it another go before going back to something that’s reaching end-of-life soon. Specifically for your issue, EF Core supports mapping to spatial data types using …

Read more