Bundling and Minification error with IIS7

.NETs standard tools for bundling and minification are a great asset to the platform solving a lot of problems with only a few lines of code.

However if using IIS 7.0 you may run into a strange issue where the path to your bundles gets created but a 404 is returned whenever there accessed. The functionality is obviously installed and working otherwise the URL wouldn’t be created, but a 404 clearly isn’t what you want.

The solution lies in your web.config file by setting runAllManagedModulesForAllRequests to true

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
    </modules>
</system.webServer>
Advertisements

Sitecore MVC Page Editor: Combining a General Link with an Image

Sitecore Page Editor

Sitecore’s Page Editor provides content authors a simple way to edit content, visually seeing the changes as they make them. To makeĀ fields on a page editable though the Page Editor simply use the field renderer function to put a field’s content on the page. When the page is viewed in page editor mode the function will output all the necessary html and javascript to make the page editor functionality work.

@Html.Sitecore().Field("Title", Model.Item)

But what if your page needs to render the contents of one field inside another? e.g. You could have a link on an image or a link surrounding a combination of other fields.

In an xslt rendering you could simply nest one tag within another:

<sc:link field="Image Link">
   <sc:image field="Image" />
</sc:link>

When you click the item in the Page Editor the toolbar would then combine the icons for the General Link field and the Image field so that you can edit the image and update the link. But with a ViewRendering in MVC, the Razer syntax used for views doesn’t support nesting items in this way.

Thankfully Sitecore have considered this and rather than using the Field function they have included a BeginField and EndField function. Between the two you can place your nested fields:

@Html.Sitecore().BeginField("Image Link", Model.Item)
    @Html.Sitecore().Field("Image", Model.Item)
@Html.Sitecore().EndField()

Unfortunately it doesn’t quite work right. The page will render correctly and the toolbar will show both options, however editing anything results in the content disappearing until you refresh the page. Thankfully there is a work around to get it to work:

@Html.Sitecore().BeginField("Image Link", Model.Item, new { haschildren = true })
    @Html.Sitecore().Field("Image", Model.Item)
@Html.Sitecore().EndField()