Questions tagged [controller]

For questions specifically related to the use of MVC controllers with Sitecore. This tag should not be used for general .NET MVC controller questions.

Filter by
Sorted by
Tagged with
0
votes
0answers
40 views

Can we create multiple ActionResults in Sitecore SXA custom controller rendering?

Per Sitecore SXA documentation, in SXA custom controller, we have to override the GetModel() method and we call repository to get the model. I would like to create multiple Action Results in Sitecore ...
0
votes
1answer
45 views

Is there any way to update the response of a controller action by pipeline process?

Is there any way that I can update the response of a controller action by pipeline process? In httpRequestEnd or httpRequestBegin for example P.S: I'm using Sitecore 9 update 1 included EXM. I created ...
0
votes
1answer
100 views

Loading of new page blocked by api call

I have a website with two pages (A and B). Both have some content which is loaded via renderings. A has a button which opens B in a new tab. A also has some frontend code which calls one of my APIs, ...
0
votes
2answers
150 views

Debugging in VS

Is there a way to debug in Visual Studio, particularly when working with controllers? Whenever I try, I get a message that says, "Unable to start debugging on the web server. The debugger cannot ...
0
votes
1answer
129 views

Sitecore 9.2 custom route api/<controller> is throwing null error

I have a requirement, When clicking the close I need to destroy the user session. For this, I have created an ajax call to destroy the session. For calling controller with the Sitecore context, I ...
1
vote
1answer
153 views

Html.Sitecore().Rendering() causes: Attempt to retrieve context object of type 'System.Web.Mvc.ViewContext' from empty stack

We have a web controller inside our Sitecore 8.2 Site that returns a search box view. The controller is exposed as an API endpoint like so: {url}/api/search/large/ When making an http web request to ...
3
votes
1answer
99 views

Context.Site.Name changes to wrong site when using AJAX call

I'm using Sitecore 9.1.1, and a multisite setup. I have a custom controller rendering that I view from a page in Site2, my controller had 2 methods: an Index() method that returns the view, and a ...
4
votes
2answers
835 views

How to pass rendering parameters for a static controller rendering

There is need to load a controller rendering from the Razor view. I'm doing it this way: @Html.Sitecore().ControllerRendering("Captcha", "GoogleReCaptcha", new { RedisCacheKeyPrefix = "scans_", ...
0
votes
0answers
123 views

Returning a file stream from a Controller

I have pdf files in folder, I want user enable to download file, in MVC controller its quite simple as below return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, filename); but ...
1
vote
1answer
254 views

OutputCache with a Sitecore controller

Using Sitecore 9.0.2, I've got code in two areas: SitecoreComponent (for controller renderings) and API (for JS calls). I've got a controller that inherits from SitecoreController in the API folder ...
0
votes
1answer
493 views

Any Best way to call the MVC action method from Hyperlink

Currently, we are having a hyperlink tag and the MVC action method is called directly from hyperlink as <a href="/api/sitecore/{controller Name}/{action Name}"> Hyperlink Text While hovering ...
1
vote
1answer
170 views

How to check access right in SitecoreController for Sitecore 9.1

In my JSON controller I want to check the access right from the User. My code looks like this public class MyController : SitecoreController { public static bool CheckAccessRight() { ...
2
votes
3answers
362 views

Sitecore 8.1 Controller Rendering Error

I am a newby and working on the Solutions Developer Course for Sitecore 8.2 online in Visual Studio with Sitecorerocks. Also just a heads up, very recently I had to rebuild this Visual Studio 2015 ...
1
vote
0answers
108 views

Getting SitecoreControllers Working With Swagger

Is there a good way to get Swagger to work with controllers that inherit SitecoreController? I've checked this blog out which uses controllers that inherit from ApiController. I thought I could get ...
2
votes
2answers
1k views

Sitecore support for async controller renderings

I am planning to use ASP.NET async pattern in my Sitecore project, but I'm getting the error: Asynchronous method which returns task as result cannot be executed synchronously Is there a way to ...
0
votes
1answer
1k views

FieldRenderer.Render for controller Rendering not “working”

I am trying to create a controller Rendering with the use of FieldRenderer.Render, but this does not work. The Controller public ActionResult PageImage() { return View(PageImageModelBuilder....
8
votes
1answer
398 views

How to Connect controller rendering with Interface Template

I am trying to create a simple Image controller Rendering and I don't want to add the template interface to my page type, because I want to add the image dynamicaly to my site. So here my "problems" ...
1
vote
1answer
48 views

Base Controller in Habitat

We are using habitat in our project. In most of our controller class of each feature, we are doing a same service call. So we are planning to have a Base Controller to avoid duplicates. Since we ...
5
votes
1answer
326 views

Sitecore 9 Platform Essentials Module 7 - Error Rendering Controller: Related Events when using an Edit Frame

I am working through the training for Sitecore 9 Platform Essentials. I am on Module 7 where they have you work on the Related Events controller and show you how to make a complex field editable in ...
3
votes
0answers
38 views

How to make two controller renderings working on same page to preserve tracking?

I have AccountsController in my solution with two methods ExportData and DeleteAccount. I have created two separate Controller Renderings with similar code: @using System.Web.Mvc @using System.Web....
0
votes
3answers
978 views

Passing an Item ID to the Controller via the Querystring

I am having an issue when passing itemid as query string to controller url is rendered like this http://sitecorelocal/api/sitecore/Product?sc_itemid=%7BB416980B-40A7-4C8F-8F98-375DD1CD9544%7 ...
4
votes
1answer
3k views

@Html.Sitecore.Field is not rendering any values

In this code model, fields are returning value but when I try to render using @Html.Sitecore().Field its returning null.For experience editor, these fields should be editable.How to do it? Am new to ...
2
votes
1answer
351 views

What is purpose of the Controllers folder in Layouts?

I've noticed that in /sitecore/layout there is a Controllers folder (first item underneath actually). In that folder you can add items of type Controller. These items have fields for a controller name ...
1
vote
0answers
87 views

Keep Sitecore Context Based On Page When Posting Back

I have a module that uses ajax to post back to the server for data. Some of this data is configurable while in experience editor. Users are winding up in a state with this module where experience ...
1
vote
0answers
665 views

Why am I receiving the error :Could not find the rendering in the HTML loaded from server [closed]

Here is my controller: namespace Website.Controllers { public class FormsController : Controller { // GET: Forms public ActionResult Index() { return View()...
0
votes
1answer
963 views

Sitecore invoking Index() method from the Controller errantly [closed]

I have a component whose assigned controller does not have an Index method. This is intentional, as the controller action is set to a specific action method. Regardless, Sitecore still attempts to ...
1
vote
2answers
507 views

I need to integrate a controller from a compiled dll into a controller I can build/control. How can I call that as a rendering?

I'm able to call this compiled dll's controller directly in a Sitecore rendering - e.g. I can create a rendering where I reference the controller, controller action, and area and the content from the ...
6
votes
2answers
598 views

IOC (Simple Injector) with EntityService

UPDATED WITH LATEST RESULTS AND QUESTION I've converted everything to pipeline and integrated Simple Injector. As I mentioned, I've never used SI before, and I'm having trouble with the controller ...
1
vote
1answer
110 views

Custom controller being overwritten by IoC

I have a simple Sitecore controller that returns an list of items from Sitecore. It's used it in a custom SPEAK UI page. This works fine in my local dev environment but when I deploy it into an ...