Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label Sitecore. Show all posts
Showing posts with label Sitecore. Show all posts

Monday, January 8, 2018

Fix : Duplicate controller Issue in Sitecore Helix project

If you are working in Sitecore Helix Framework and going to call action method like  http://myinstance/api/sitecore/accounts/RenderResetPassword, you may get error like

Server Error in '/' Application.

Multiple types were found that match the controller named 'accounts'. This can happen if the route that services this request ('api/sitecore/{controller}/{action}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.

The request for 'accounts' has found the following matching controllers:
Feature.Abc.Accounts.Controllers.AccountsController
Feature.Xyz.Accounts.Controllers.AccountsController

It’s because of duplicate controller name in Abc and Xyz project.

To fix this, we have to register custom MVC routes in Sitecore. For this, I created one custom processor file “RegisterCustomRoute.cs” to initialize pipeline.

You have to register your duplicate controller as

    public class RegisterCustomRoute
    {
        public virtual void Process(PipelineArgs args)
        {
            RouteTable.Routes.MapRoute
                ("AbcAccount",
                "abc/{controller}/{action}/{id}",
                new { controller = "Accounts", id = UrlParameter.Optional },
                new[] { "Feature.Abc.Accounts.Controllers" }
                );

            RouteTable.Routes.MapRoute
                ("XyzAccount",
                "xyz/{controller}/{action}/{id}",
                new { controller = "Accounts", id = UrlParameter.Optional },
                new[] { "Feature.Xyz.Accounts.Controllers" }
                );
                        }
    }

Here I have append “abc” and “xyz” to separate the URL for account and specified their Namespace as last parameter in MapRoute() method.  Now you can call new URL as

With this you don’t need to put “api/sitecore” in URL now for accounts controller.

I registered this Processor entry in config patch file customweb.config

    <pipelines>
      <initialize>
        <processor type="MyProject.Website.RegisterCustomRoute, MyProject.Website" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
      </initialize>
    </pipelines>

If you are facing the same error, make sure to add entry in “RegisterCustomRoute.cs” as highlighted above.

Thursday, November 30, 2017

Short Video : Language fallback in Sitecore media items

Watch this Sitecore video for quick understanding on Language fallback in media items.




Wednesday, October 18, 2017

Sitecore 9 updates



I was eagerly waiting for Sitecore 9. Now Sitecore 9 is officially released and available for download at https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform/90/Sitecore_Experience_Platform_90_Initial_Release.aspx


Here is the minimum requirement for running Sitecore XP 9

IIS
  • IIS 10.0
  • IIS 8.5
Operating Systems
  • Windows Server 2016
  • Windows Server 2012 R2 (64-bit)
  • Windows 10 (32/64-bit)
  • Windows 8.1 (32/64-bit)
.NET Framework
4.6.2 or later
Visual Studio
Microsoft Visual Studio 2015 or later
Database
  • Microsoft SQL Server 2016 SP1
  • Microsoft SQL Server 2014 SP2
Browsers
  • Microsoft Internet Explorer 11.
  • Mozilla Firefox 54, 55, 56.
  • Google Chrome 60, 61.
  • Microsoft Edge 40.
  • Apple Safari 9, 10, 11.
Hardware requirement
  • 4 core processor
  • 16GB of RAM

So what are you waiting for guys? Download, install and start playing with Sitecore 9.