Hack in a new EpiServer user so you can log in

Recently, our team needed to access the EpiServer admin panel, but we didn't have a valid username/password. With the help of Jon B Jones's post on the topic the following simple solution got us past the hurdle.

Create an ASPX page

Within the root of your project, create a new ASPX such as CreateUser.aspx. Fill in the username, password and email parameters with your details.

<%@ Page Language="C#" AutoEventWireup="true" %>

<%
    try
    {
        Roles.CreateRole("WebAdmins");
    }
    catch (Exception)
    {
        //  Role exists, swallow error
    }

    try
    {
        // Set your user details for the new account
        var username = "";
        var password = "";
        var email = "";

        var user = Membership.CreateUser(username, password, email);
        user.IsApproved = true;

        Roles.AddUserToRole(username, "WebAdmins");

        Response.Write("User successfully created");
    }
    catch (Exception e)
    {
        Response.Write(e.Message);
    }
%>

Create the user

When you've completed the above CreateUser.aspx page, run the project and navigate to /CreateUser.aspx. This will run the above code and create the user with the details you've set.

Now your user account should have been created, navigate to /episerver and log in.

Delete the ASPX page

Assuming all went well above you should now be able to access EpiServer with the new user account. It's important to remove the ASPX page we've just created as we don't want this to be deployed anywhere accidentally. So delete the CreateUser.aspx page and ensure this was not committed to source control.