0

I have implemented one solution using Sitecore 8.1 MVC , Castle Windsor and glass mapper v3.5. In this solution we have two MVC project but it may contains multiple website(Glass_Sample, Glass_Sample_1, and so on)

Glass_Global: That’s why global/common functionality(castle windsor) implemented in this project and used by other website(Glass_Sample).I put the castle windsor implementation in this project:

enter image description here

and put the Glass_Global.config file inside App_Config/Include folder

<pipelines>
      <initialize>
        <processor type="Glass_Global.Pipelines.CastleWindsor.CastleWindsorConfig, Glass_Global" />
        <processor type="Glass_Sample.Pipelines.CastleWindsor.CastleWindsorConfig, Glass_Sample" />
      </initialize>
 </pipelines>

Glass_Sample: This will be first website in this solution to start.I have added CastleWindsorConfig.cs file in this project

enter image description here

public class CastleWindsorConfig
    {
        public void Process(PipelineArgs args)
        {
            WindsorContainer container = new WindsorContainer();
            container.Install(FromAssembly.This());
            GlobalConfiguration.Configuration.DependencyResolver = new WindsorDependencyResolver(container);
            container.Register(Classes.FromThisAssembly().BasedOn<IController>().LifestyleTransient());
            container.Register(Component.For<ICommon>().ImplementedBy<CommonService>().LifestyleTransient());
            IControllerFactory controllerFactory = new WindsorControllerFactory(container);
            SitecoreControllerFactory scSitecoreControllerFactory = new SitecoreControllerFactory(controllerFactory); 
            System.Web.Mvc.ControllerBuilder.Current.SetControllerFactory(scSitecoreControllerFactory);
        }
    }

I am using controller rendering on Home page layout of this Glass_Sample website but when I browse the website I got following error:

enter image description here

Did I miss anything?

I put my Controller,Interface inside Areas folder Is that is the root cause of this error?

enter image description here

Any suggestion?

PS

It's working now.Actually I created a new Glass_Sample.config file and put inside Glass_Sample/App_Config/Include folder:

<pipelines>
      <initialize>
        <processor type="Glass_Sample.Pipelines.CastleWindsor.CastleWindsorConfig, Glass_Sample" />
      </initialize>
 </pipelines>

Now this solution may contains multiple website.Should I follow the following approach for adding a new website in this solution:

  1. Will Add a new MVC project in this solution and add required sitecore assemblies

  2. go to the IIS , add a new application (GlassSampleSite1) and copy the sitecore folder/dlls from GlassSample website folder

3.Go to the solution and right click on GlassSampleSite1 project and set the publish target to newly created instance GlassSampleSite1/Website folder and do publish.

Will thi work?

Sukhjeevan
  • 3,074
  • 9
  • 46
  • 89

0 Answers0