Friday, June 27, 2014

IIS ARR Reverse Proxy and HTTP Status Code 304

In IIS 7.5, reverse proxy using ARR v2, does not send 304 status code for subsequent requests which are cached on file system. Because of this, even if the actual website allows caching of requests in browser (client side), ARR always sends HTTP 200 code. This forces the browser to download the cached request again from server.

For some strange reason, ARR always send status code 200 if requests contains ETags.
So, basically if you want ARR to send 304 status code then ETags must be removed.

In IIS, Etags can be removed from response with the help IIS URL Rewrite module. Following outbound rule must be created to remove ETags:

  <rule name="Remove ETag">
    <match pattern=".+" servervariable="RESPONSE_ETag">
    <action type="Rewrite" value="">

For more details check below links:

Wednesday, June 25, 2014

Reading Complex Field Values in Sitecore WFFM

Sitecore Web Forms for Marketers is a Sitecore CMS module used for creating forms in a website. It has various set of fields like simple, list, complex, pre-filled etc.

Usually to access field value in code, Value property of AdaptedControlResult class is used.
For any list or complex types of fields, the Value property normally contains extra information.

For e.g., A WFFM form has a check-box list and the values for its items are 1,2,3,4,5. User selects 1,2,3 and submits the form.
Then in the server-side code the value of this field is:


To get a simple value with out item tags then GetSitecoreStyleValue method of FieldReflectionUtil class can be used.
Example code snippet:

AdaptedResultList fields;

// Get the form field by specifying the field name
AdaptedControlResult formField = fields.GetEntryByName("fieldName"); 

// complex value with item tags
string fieldValue = formField.Value;

// simple value without item tags
fieldValue = Sitecore.Form.Core.Utility.FieldReflectionUtil.GetSitecoreStyleValue(formField.FieldID, fieldValue);

BottomLine: Use FieldReflectionUtil class to get simplified version of form field values.

Tuesday, June 24, 2014

Extension Randomly Added in Sitecore Media Item URLs

In Sitecore 6.6, MediaManager randomly adds extension while generating URL for any Sitecore Media Item. This is a bug in Sitecore. A workaround is available to fix this issue.
MediaUrlOptions mediaUrlOpts = new MediaUrlOptions();
mediaUrlOpts.IncludeExtension = false;
Response.Write(MediaManager.GetMediaUrl(item, mediaUrlOpts));

In case extension is always needed in the URL then set IncludeExtension property to true.