3

I am very new to Sitecore, trying to implement a basic controller inheriting from StandardController. I've followed the official Sitecore docs for setting up the environment to work with MVC here: Sitecore for development. It's written that the nuget packages to be installed are: Sitecore.Kernel, Sitecore.Mvc, Sitecore.Mvc.Analytics

I've installed them in the same order, targeting the same package version as my Sitecore installed instance: 8.2.170728, based on the nuget repository indicated here: https://sitecore.myget.org/F/sc-packages/api/v3/index.json

Even after I complete the setup indicated in the doc, I don't find any namespace containing the StandardController class. The namespace should be starting with something like: Sitecore.SX...

P.S: installed .NET framework is v4.6.1, using VisualStudio 2017

Below is what I have installed effectively after installing Version 8.2.170728 of these nuget packages: Sitecore.Kernel, Sitecore.Mvc, Sitecore.Mvc.Analytics

enter image description here

  • Namespace: Sitecore.XA.Foundation.Mvc.Controllers.StandardController. Assembly: Sitecore.XA.Foundation.Mvc. – Dawid Rutkowski Feb 6 '18 at 10:48
  • I can't seem to find neither the assembly nor the namespace. I can't figure what I'm missing out. I'll add a screenshot of what I have after installing the nuget packages I've mentioned – JohnnyCors Feb 6 '18 at 13:24
4

The XA dlls are not yet available from nuget (but they will be). At this point you can create a source-controlled /lib folder in your solution and reference the needed .XA dlls from there.

1

StandardController comes from the Sitecore.XA.Foundation.Mvc assembly, which is part of the SXA package.

Are you trying to work with SXA? If so, first you have to install the SXA package in your Sitecore instance - https://dev.sitecore.net/Downloads/Sitecore_Experience_Accelerator/16/Sitecore_Experience_Accelerator_16_Initial_Release.aspx - and then reference the right assemblies in your project. I believe you are following this tutorial.

Now, if you are simply trying to create a controller you can use the SitecoreController as base. This class comes from the Sitecore.Mvc assembly.

  • thanks for answering. Yes I use SXA, I have already installed it using Sitecore's Backoffice through the control panel, and it's working fine. Yes again, I try to create a simple controller and cannot find the namespace you mentioned: Sitecore.XA.Foundation.Mvc. I've installed the nuget package Sitecore.Mvc – JohnnyCors Feb 6 '18 at 13:13
  • Another precision might be helpful, my visual studio solution lives outside the installed Sitecore instance – JohnnyCors Feb 6 '18 at 16:10
1

I finally added the reference to the Sitecore.XA.Foundation.Mvc DLL which lives in my installed sitecore instance bin/ directory.

I don't believe this is the right way to do it. So I'm leaving it open.

  • This is really the right way. Close this question ;) – Peter Procházka Mar 7 '18 at 19:53
1

It's now available in the Sitecore nuget feed v3:

https://sitecore.myget.org/F/sc-packages/api/v3/index.json

From there, you can install the Sitecore.XA.Foundation.Mvc package in your project and reference the Sitecore.XA.Foundation.Mvc.Controllers in your code.

1

This issue only happens (at least on "my machine") when using PackageReference instead of Packages.config.

A way to fix this is to edit the .csproj and change:

<PackageReference Include="Sitecore.XA.Foundation.Mvc">
  <Version>4.8.0</Version>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
  <PrivateAssets>all</PrivateAssets>      
</PackageReference>

to

<PackageReference Include="Sitecore.XA.Foundation.Mvc">
  <Version>4.8.0</Version>
  <PrivateAssets>none</PrivateAssets>      
</PackageReference>

I got into this solution after read this: https://github.com/NuGet/Home/issues/7686

  • This worked for me with PackageReferences and SXA 1.8.1 as well. – Corey Smith Jun 9 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.