Questions tagged [mvc]

For questions relating to ASP.NET MVC implementations. The ASP.NET MVC is a web application framework developed by Microsoft, which implements the model–view–controller pattern.

Filter by
Sorted by
Tagged with
22
votes
2answers
5k views

How do I implement Accelerated Mobile Pages (AMP) with Sitecore?

This is just a general question. Has anyone implemented AMP with Sitecore before? Is it possible, how difficult and could you point me in the direction of documentation?
14
votes
3answers
17k views

C# MVC razor view - HtmlHelper does not contain a definition for 'Sitecore'

Has anyone experienced an error described in the image below where the HtmlHelper in razor view is not recognizing Sitecore when I try to specify a placeholder? Thanks for your help!
13
votes
4answers
19k views

Accessing the Data Source of a Control

I have a control property with a data source pointing to a folder with items with fields. Is there a way to loop through the children of the item in the data source and display them on my view? In ...
12
votes
2answers
7k views

why is my Richtext field not rendering as rich text?

this is the value on my Rich text field: <p><strong>Did you know the monarch population has declined by more than 90 percent?</strong> Did you know that much of the monarch summer ...
12
votes
3answers
1k views

MVC equivalent of SecurityCheck Pipeline Processor

What is the pipeline processor responsible for redirecting the user to the login page if they do not have access to the page being loaded? In a Sitecore webforms solution, this is handled by the ...
11
votes
2answers
2k views

Create controller rendering in SXA

As a test, I wanted to create a rendering for an SXA site. It had to be added to the toolbox and have a controller, model, and view. I read this Creating new renderings that are compatible with SXA ...
10
votes
1answer
6k views

InvalidOperationException: No route in the route table matches the supplied values

I've recently deployed a SC 8.1 update 3 site to production (seperate CM and CD) and on the CD side I'm getting this error: Server Error in '/' Application. No route in the route table matches the ...
10
votes
2answers
2k views

Change redirect url after success in WFFM

I have a WFFM form with a hidden field on it. The field contains a value that I would like to know on the success page - in order to use it in custom code in a rendering or even for personalization. ...
10
votes
1answer
4k views

How do I set up my Sitecore MVC Post form and receive a confirmation page

I have not ever had to submit a form in Sitecore before, in my previous experience I used WFFM, thus I didn't have to create or process forms. My form is simply to take in some information and ...
9
votes
4answers
6k views

Why is my Ajax url not recognizing my sitecore controller or hitting my breakpoint in my sitecore controller?

this is my markup: the ajax is supposed to get called when there is a change to my dropdown selection: this is my ajax jquery: <script> $("#AffiliateList").change(function (e) { ...
9
votes
1answer
4k views

Handle all Custom Errors in Sitecore MVC

I've edited a patched a pipeline using the following bit of code. <sitecore> <pipelines> <mvc.exception> <processor type="Sitecore.Mvc.Pipelines.MvcEvents.Exception....
9
votes
3answers
1k views

Disable submit button on MVC form that has slow action

I have a Sitecore 8.1 WFFM form in an MVC form rendering, with a save action that takes a few seconds to complete. After submitting the form, the user just sees the form page they submitted with no ...
8
votes
2answers
2k views

Is it possible to use conditional renderings with Sitecore MVC

I have problems using conditional renderings with MVC (on Sitecore 8.0 rev. 150121) I've created a condition and assigned it to the controller rendering but this condition never gets called. From ...
8
votes
3answers
5k views

How to Render Javascript per page or component?

So I have renderings that depend on specific CSS or specifically Javascript. Do you load the same Javascript on all pages even if the Javascript is for a specific page/rendering, or do you pull in ...
8
votes
2answers
4k views

How do I do custom forms in Sitecore MVC?

I am trying to get a form in my MVC Controller Rendering to work. I have read these posts: https://mhwelander.net/2014/05/30/posting-forms-in-sitecore-mvc-part-2-controller-renderings/ https://ctor....
8
votes
3answers
2k views

What's an efficient Frontend development process / workflow for Sitecore?

Does anyone have a Frontend development/prototyping process/workflow that has proven to be effective and efficient? I have multiple sites running on Sitecore. We are also MVC based. As a Frontend ...
8
votes
1answer
440 views

Upgrade path from Integrated Dynamic Placeholders to Sitecore 9 Dynamic Placeholders (OOTB)

Does anyone have a SPE script that could be used to upgrade the rendering parameters of existing content to the new dynamic placeholder style required for Sitecore 9 Dynamic placeholders? We used to ...
7
votes
4answers
4k views

Sitecore MVC - Images Inside foreach Loop & RenderingModel for Strongly Typed Views

I have a couple follow-up questions for this question: Sitecore MVC - Accessing the Data Source of a Control In the foreach loop, how do I output an image? Since the model for the view is now ...
7
votes
2answers
4k views

Custom Item Resolver not setting context item

I have a custom item resolver where I am trying to set the context item based on the path in the url (this is for a re-written url). I've patched this in after Sitecores ItemResolver and it runs fine. ...
7
votes
1answer
818 views

Item not found when saving page in Experience Editor

I have a strange situation where I get a 'Item not found' on postback in Experience Editor when I edit an page. The culprit is a controller rendering which has a line of code in to get the current ...
7
votes
2answers
1k views

Sitecore Custom MVC Form with file upload, file always null

I have the following model public class VacancyDetailModel { public HttpPostedFileBase Resume {get;set; } } This is my form. @using (Html.BeginForm()) { <input type="file" name="Resume" /&...
7
votes
1answer
4k views

How to use Dynamic Placeholders

This is my first time with Dynamic Placeholders and I am unable to find any related tutorial. I have installed the nuget package mentioned in the Fortis Site https://www.nuget.org/packages/...
7
votes
1answer
889 views

AntiForgery Tokens and Sitecore Development

I have set up some Sitecore extranet users (8.1.160519). I am using MVC AntiForgeryTokens for some posts. The problem is with the login form explicitly. When I am developing I am logged in as Admin ...
7
votes
2answers
874 views

How to override/replace the default Sitecore Authentication Controller

I upgraded my site from 7.5 to 8.1 and when I try to click on Sitecore logout link I have the following error: Multiple types were found that match the controller named 'Authentication'. ...
7
votes
2answers
2k views

Rendering Caches not working

I have a problem with my HTML cache always being empty when I look at the cache report screens in Sitecore I have done the following: Enabled Cacheable and Vary By Data on each rendering in Sitecore (...
7
votes
2answers
2k views

Error when using custom routes with https: “Attempt to retrieve context object of type 'Sitecore.Mvc.Presentation.RenderingContext' from empty stack.”

We have a login/register modal that is being called via javascript on the front end. I created a custom route to point to the right action controller, and it works fine in every environment - except ...
7
votes
1answer
798 views

Sitecore component CSS and script handling in an HTTP/2 environment

First project using Helix coming up. In our previous project we've used HTTP/2 on the CDN, so we have adopted a lot of new best practices. One of the most important new best practices in HTTP/2 is ...
6
votes
1answer
8k views

How to redirect to another page or sitecore item in MVC

I'm new to MVC and trying to achieve page redirection. User will click on "Sign-out" and should be redirected to the "sign-in" page. Here is my code. public ActionResult SignIn() { if (Sitecore....
6
votes
3answers
205 views

Shared data between root- and subcomponents in placeholder while having a loose coupling between them

I have a nested component structure, where my root element has a placeholder, which contains zero to many sub-components. Each sub-component has it's own price, which gets calculated inside the sub-...
6
votes
2answers
7k views

Sitecore MVC - Controller Renderings - View Model for Custom Item

How do I bind a Custom Item generated with "Custom Item Generator" to my view model for a controller rendering? There is a data source that is returning a list of the Custom Items. Also, one of the ...
6
votes
1answer
18k views

Redirecting to another item in an AJAX request

I am using Sitecore 8.2 with MVC. I am trying to perform a page redirect, but my code isn't working. I'm calling an MVC controller action method from JavaScript using a jQuery AJAX call. The ...
6
votes
1answer
327 views

Pre-populate form fields in WFFM

I have a requirement to pre-populate fields from an external source. Is there a way to hook into a pipeline to achieve this? I'm thinking something similar to how Sitecore can populate the fields by ...
6
votes
2answers
345 views

WFFM MVC and WFFM Webforms in the same instance

Has anyone tried this? Is this possible? Do they interfere with each other in any way? We have a legacy Sitecore instance with many sites on it. The plan is to move them to MVC one by one. But WFFM ...
6
votes
2answers
1k views

How do I display a child's presentation details? (Nested presentation details)

I have a Sitecore item that has presentation details ("MainPage"). Within those details is a component that also has presentation details ("PageSlide"). I cannot get Sitecore to display the ...
6
votes
2answers
464 views

Glass Cast issues after upgrading from Sitecore 7.2 to 8.2

So, I upgraded a Sitecore solution from 7.2 to 8.2. All works well, except for the site. I keep on getting the error in my views like the one below: The model item passed into the dictionary is of ...
6
votes
2answers
2k views

What's the option for calling a controller on a Sitecore MVC Layout?

Basically, I'd like to define a MVC layout in Sitecore, and have that layout be linked to both a controller and a razor file. Currently there are only options to set the Razor file, not the ...
6
votes
1answer
1k views

ItemResolvers not working as expected

Using Sitecore 8.1 I have two custom ItemResolvers in my site, in this order: ItemResolver (The sitecore default) ProductItemResolver (Determines if a product exists for a wildcard item) ...
6
votes
1answer
1k views

Postback Does Not Return Full Page Layout

Sitecore Version: 8.2 (rev 170614) Glass.Mapper Version: 4.4.0.199 .NET Framework Version: 4.6 I have a Controller Rendering that represents "Redemption" form on my site that can be added ...
6
votes
1answer
447 views

Sitecore 8.2 MVC site setup and Issues

I am creating a Sitecore 8.2 MVC test website and I am getting a couple of errors and client form validation Issues. Get methods are working fine but the post method is not working. I have exact same ...
6
votes
1answer
63 views

Is WFFM with MVC supported in Sitecore 7.1?

We are on Sitecore 7.1 (rev. 140324) and need to use WFFM with MVC. Therefore I would like to check if Sitecore 7.1 (rev. 140324) supports WFFM with MVC.
5
votes
4answers
5k views

Passing a parameter to controller rendering through URL

I have a component on my page that is a controller rendering and I'd like to pass a parameter in through the URL, but not as a query string parameter. So, instead of site.com/product?id=123, I want: ...
5
votes
2answers
1k views

Can we design the View renderings with multiple data sources?

I am doing project in Sitecore MVC. For every view rendering we are giving one data source for model reference but I need to get the field values from multiple items. So can we design the view ...
5
votes
2answers
7k views

How to render an MVC rendering in code

I have two renderings. Let's call them Form Block and Complete Form. Complete Form has a placeholder on it that can contain Form Blocks. Form Blocks have a placeholder that can contain other ...
5
votes
1answer
884 views

How to return 401 page instead of login page when logged in user doesn't have permission

Currently, when a logged in user tries to access a page that they do not have permission to (because they don't have a certain role), Sitecore seems to redirect the user to the login page. This is ...
5
votes
1answer
492 views

Code to determine if a specific component is already on page

Issue: I want to add two accordion components to one page. The IDs are the same so both of the components will not work. My Proposed Solution: Using MVC, add code to the component that will check if ...
5
votes
3answers
5k views

Error with controller rendering - “does not implement IController”

Using Sitecore 8.2 I have multiple MVC projects in a VS Solution. For each project, I remove the RouteConfig.cs, but for one, I forgot and clicked on publish. (I'm not sure if thats the reason for ...
5
votes
1answer
652 views

How can I append HTML within and before the text of a rendered Link Field?

I have a General Link field in Sitecore that I would like to append some HTML to. I know that I can create a custom extension method and put what I want after the link's text by doing the following: ...
5
votes
1answer
394 views

Force controller rendering in head of page to render after other renderings

I know that MVC and by definition Sitecore MVC renders components from top to bottom order, but is there any way to force (hack) a controller rendering (which is used in the head of the page) to be ...
5
votes
2answers
2k views

How do you programmatically get the HTML from a Sitecore item, including all its renderings?

I'm trying to programmatically get the HTML from an item, including its presentation details (i.e. placeholder items inserted via Experience Editor). I'm using the top solution from this post but it ...
5
votes
3answers
828 views

Upgrading from 7.2 to 8.2

We are upgrading from Sitecore 7.2 to 8.2. In 7.2, we have many sublayouts (.ascx controls). What's the best practice on upgrading those? Should we just migrate the site with the sublayouts or do we ...