Skip to content

Instantly share code, notes, and snippets.

Erik Henningson ErikHen

Block or report user

Report or block ErikHen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ErikHen / Login.cshtml
Created May 11, 2017
Episerver Mixed-mode auth. Login view
View Login.cshtml
@{ Layout = null; }
@model MyNamespace.Models.LoginViewModel
<!DOCTYPE html>
<title>Log in</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex,nofollow" />
ErikHen / LoginController.cs
Created May 11, 2017
Episerver Mixed-mode auth. Login controller
View LoginController.cs
namespace MyNamespace.Controllers
public class LoginController : Controller
private UIUserProvider UIUserProvider => ServiceLocator.Current.GetInstance<UIUserProvider>();
private UISignInManager UISignInManager => ServiceLocator.Current.GetInstance<UISignInManager>();
public ActionResult Index()
return View("/Views/Shared/Login.cshtml");
ErikHen / Global.asax.cs
Created May 11, 2017
Episerver Mixed-mode auth. Register route
View Global.asax.cs
protected override void RegisterRoutes(RouteCollection routes)
routes.MapRoute("Custom login", "Login/{action}/", new { controller = "Login", action = "Index" });
ErikHen / LoginViewModel.cs
Created May 11, 2017
Episerver Mixed-mode auth. Login view
View LoginViewModel.cs
public class LoginViewModel
[Display(Name = "Username")]
public string Username { get; set; }
[Display(Name = "Password")]
View MapBlock.cs
[Display(Name = "Address or coordinates", Description = "Coordinates must be separated by white-space (e.g. \"55.5615205 12.9749824\")", Order = 40)]
[AutoSuggestSelection(typeof(GoogleMapsGeocoding), AllowCustomValues = false)]
public virtual string MapCoordinates { get; set; }
View GoogleMapsGeoCoding
namespace MyNamespace
public class GoogleMapsGeocoding : ISelectionQuery
private readonly string _googleApiKey;
public GoogleMapsGeocoding()
//get key from config
_googleApiKey = ConfigurationManager.AppSettings["GoogleGeocodingApiKey"];
ErikHen / Startup.cs
Created May 2, 2017
Episerver Federated security
View Startup.cs
using System;
using System.Configuration;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web.Helpers;
using EPiServer.Cms.UI.AspNetIdentity;
using EPiServer.Security;
using EPiServer.ServiceLocation;
using Microsoft.Owin;
using Microsoft.Owin.Extensions;
ErikHen / Startup.cs
Created May 8, 2017
Episerver mixed-mode authentication
View Startup.cs
namespace MyNamespace.Web
public class Startup
const string LogoutUrl = "/util/logout.aspx";
public void Configuration(IAppBuilder app)
// Add CMS integration for ASP.NET Identity
View SetupEpiAzureEnvironment.ps1
$webappname = "myepienvironment" # Application name (lowercase alphanumeric only)
$subscriptionname = "My subscription name"
$resourcegroupname ="$($webappname)-resourcegroup"
$location="West Europe"
$sqlservername = "$($webappname)-sqlserver"
$sqladminlogin = "SaUser"
$sqlpassword = "YourSecretAdminPassword1"
# The ip address range that you want to allow to access your SQL server - change as appropriate
$startip = ""
View LoginToAzure.ps1
function Login() {
$azureappid ="45d6472e-0526-4a12-8c58-959f697eb296" #your Azure application id
$azurepassword = ConvertTo-SecureString "YourSecretPassword" -AsPlainText -Force
$pscred = New-Object System.Management.Automation.PSCredential($azureappid, $azurepassword)
Login-AzureRmAccount -Credential $pscred -ServicePrincipal -TenantId "31d2b6c6-a122-456c-b9a5-af2d7e3fbf0f" #you Azure subscription Tenant id
You can’t perform that action at this time.