Try our conversational search powered by Generative AI!

Sergii Vorushylo
Nov 8, 2012
  4607
(0 votes)

Navigate to Edit mode instead of Dashboard in EPiServer CMS 6

There is a question on the forum regarding how to change the default mode when navigating to the protected path in EPiServer CMS 6. Customer wants to get into Edit mode instead of Dashboard when navigating to <yourSiteUrl>/<yourProtectedUrl>. I think that answer to this question worth a small post here.

Routing to the Dashboard is controlled by a special module called EPiServer.Shell.Web.Routing.ShellRoutingModule. It can be replaced with your own implementation. Here is how it can look like if you want your users to be redirected to Edit mode instead of Dashboard:

public class CustomRoutingModule : UrlRoutingModule
{
private static object _orignalPathKey = new object();

/// <summary>
/// Matches the HTTP request to a route, retrieves the handler for that route, and sets the handler as the HTTP handler for the current request.
/// </summary>
/// <param name="context">Encapsulates all HTTP-specific information about an individual HTTP request.</param>
public override void PostResolveRequestCache(HttpContextBase context)
{
string protectedPath = EPiServer.Shell.Paths.ProtectedRootPath;
string requestedPath = context.Request.CurrentExecutionFilePath;
if (string.Equals(protectedPath.TrimEnd('/'), requestedPath.TrimEnd('/'), StringComparison.OrdinalIgnoreCase))
{
context.Items[_orignalPathKey] = requestedPath;
context.RewritePath(protectedPath + "cms/edit/default.aspx");
}

base.PostResolveRequestCache(context);
}

/// <summary>
/// Assigns the HTTP handler for the current request to the context.
/// </summary>
/// <param name="context">Encapsulates all HTTP-specific information about an individual HTTP request.</param>
public override void PostMapRequestHandler(HttpContextBase context)
{
base.PostMapRequestHandler(context);

string requestedPath = context.Items[_orignalPathKey] as string;
if (requestedPath != null)
{
context.RewritePath(requestedPath);
}
}
}

You also need to replace ShellRoutingModule with a CustomRoutingModule in the web.config in configuration/system.webServer/modules:

<!-- add name="ShellRoutingModule" type="EPiServer.Shell.Web.Routing.ShellRoutingModule, EPiServer.Shell" /-->
<add name="CustomRoutingModule" type="MyRoutingModule.CustomRoutingModule, MyRoutingModule" />

After that, your users will be able to navigate to Edit mode with the same URL that before was used for Dashboard. However, the Start menu and Dashboard context menu will navigate to Edit mode as well, thus making Dashboard unavailable from menus. To fix this, you need to remove default routes for the Shell module defined in C:\Program Files (x86)\EPiServer\Framework\6.2.267.1\ Application\UI\module.config:

...
<route>
<!--defaults>
<add key="moduleArea" value="Shell" />
<add key="controller" value="Dashboard" />
<add key="action" value="Index" />
<add key="id" value="" />
</defaults-->
</route>
...

The last changes will affect all EPiServer sites on the server, so you might consider creating a copy of the whole folder containing module.config and pointing physicalPath attribute of the EPiServerShell virtual path provider to the new folder.

Nov 08, 2012

Comments

Ted
Ted Nov 9, 2012 02:18 PM

We've had the same request, but in our case we simply used the URL Rewrite module in IIS to redirect requests for the UI path.

Essentially redirecting the request before it even reaches the site.

In other words, when browsing to http://thesite.com/EPiServer you get redirected to http://thesite.com/EPiServer/CMS/Edit.

Not sure if there are any pros/cons to the different approaches?

Nov 9, 2012 02:49 PM

@Ted: It sounds much simpler. But you still have to change the defaults for the Shell module routes, right? Otherwise the Start/Dashboard menu will navigate to the edit mode as well.

Ateeq pasha
Ateeq pasha May 30, 2014 08:35 AM

Hi Sergii Vorushylo ,

when i am trying using your code part its showing the EPiServer.Shell.Paths.ProtectedRootPath reference missing error
can you please tell me the which reference file i need to add.

Jun 2, 2014 08:40 AM

@Ateeq you should add a reference to EPiServer.Shell.dll

Please login to comment.
Latest blogs
Why C# Developers Should Embrace Node.js

Explore why C# developers should embrace Node.js especially with Optimizely's SaaS CMS on the horizon. Understand the shift towards agile web...

Andy Blyth | May 2, 2024 | Syndicated blog

Is Optimizely CMS PaaS the Preferred Choice?

As always, it depends. With it's comprehensive and proven support for complex business needs across various deployment scenarios, it fits very well...

Andy Blyth | May 2, 2024 | Syndicated blog

Adding market segment for Customized Commerce 14

Since v.14 of commerce, the old solution  for adding market segment to the url is not working anymore due to techinal changes of .NET Core. There i...

Oskar Zetterberg | May 2, 2024

Blazor components in Optimizely CMS admin/edit interface

Lab: Integrating Blazor Components into Various Aspects of Optimizely CMS admin/edit interface

Ove Lartelius | May 2, 2024 | Syndicated blog

Anonymous Tracking Across Devices with Optimizely ODP

An article by Lead Integration Developer, Daniel Copping In this article, I’ll describe how you can use the Optimizely Data Platform (ODP) to...

Daniel Copping | Apr 30, 2024 | Syndicated blog

Optimizely Forms - How to add extra data automatically into submission

Some words about Optimizely Forms Optimizely Forms is a built-in add-on by Optimizely development team that enables to create forms dynamically via...

Binh Nguyen Thi | Apr 29, 2024