Sitecore, Web

Sluggish Sitecore Development Environment? Here’s An Easy Method To Disable Sitecore Analytics

When you install a new 8.0 instance of Sitecore you will find the site can be laggy and sluggish to load. To speed up your dev environment I would recommend this easy fix.

First create a folder called z in your app config sitecore path: C:\inetpub\wwwroot\yoursitecore\Website\App_Config\z

Then, create a file called zwoa.config and paste the following in:

<configuration xmlns:patch="<a href="http://www.sitecore.net/xmlconfig/">http://www.sitecore.net/xmlconfig/</a>">
 <sitecore>
 <pipelines>
 <initialize>
 <processor type="Sitecore.Pipelines.Initialize.PrecompileSpeakViews, Sitecore.Speak.Clientpro" >
 <patch:delete />
 </processor>
 <processor type="Sitecore.ContentTesting.Pipelines.Initialize.RegisterContentTestingCommandRoute, Sitecore.ContentTesting" >
 <patch:delete />
 </processor>
 <processor type="Sitecore.Pipelines.Initialize.PrecompileSpeakViews, Sitecore.Speak.Client" use="ContentTesting" >
 <patch:delete />
 </processor>
 </initialize>
 <mvc.renderPageExtenders>
 <processor patch:after="processor[@type='Sitecore.Mvc.ExperienceEditor.Pipelines.RenderPageExtenders.RenderExtendersContainer, Sitecore.Mvc.ExperienceEditor']" type="Sitecore.Mvc.ExperienceEditor.Pipelines.RenderPageExtenders.RenderPageEditorExtender, Sitecore.Mvc.ExperienceEditor"></processor>
 <processor patch:after="processor[@type='Sitecore.Mvc.ExperienceEditor.Pipelines.RenderPageExtenders.RenderExtendersContainer, Sitecore.Mvc.ExperienceEditor']" type="Sitecore.Mvc.ExperienceEditor.Pipelines.RenderPageExtenders.RenderPreviewExtender, Sitecore.Mvc.ExperienceEditor"></processor>
 <processor patch:after="processor[@type='Sitecore.Mvc.ExperienceEditor.Pipelines.RenderPageExtenders.RenderExtendersContainer, Sitecore.Mvc.ExperienceEditor']" type="Sitecore.Mvc.ExperienceEditor.Pipelines.RenderPageExtenders.RenderDebugExtender, Sitecore.Mvc.ExperienceEditor"></processor>
 <processor type=""Sitecore.Mvc.ExperienceEditor.Pipelines.RenderPageExtenders.SpeakRibbon.RenderPageEditorSpeakExtender, Sitecore.Mvc.ExperienceEditor" >
 <patch:delete />
 </processor>
 </mvc.renderPageExtenders>
 </pipelines>
 <settings>
 <setting name="Analytics.Enabled" > <patch:attribute name="value" value="false" />
 </setting>
 </settings>
 </sitecore>
 </configuration>

Refresh your Sitecore in a web browser and watch it go!

C#, Email, Programming, Web

Programmatically Send An Email Message With An Html Body (C#)

I have used the following snippet many times in the past. I would recommend validating your string values if the values are dynamic. I would also recommend placing your email attempt in a try/catch so you will not break your web application if there is some kind of issue on the email server itself. Anyway, hope this helps.

using System.Net.Mail;

// server settings
SmtpClient client = new SmtpClient();
client.Port = 25;
client.Host = "exchangeserver.yourdomain.com";

// declasre mail message
MailMessage mm = new MailMessage();

// from
mm.From = new MailAddress("donotreply@yourdomain.com");

// to
string toemail = "";
toemail = "persontosendto@yourdomain.com";
mm.To.Add(new MailAddress(toemail));

// cc
string toemailcc = "";
toemailcc = "another_person@yourdomain.com";
mm.CC.Add(new MailAddress(toemailcc));

// subject
mm.Subject = "The All Important Subject";

// body
string message = "";
message = "This is the all important email body message. &lt;br /&gt;&lt;br /&gt;";
message = message + "Sincerely yours, &lt;br /&gt;&lt;br /&gt;";
mm.Body = message;
mm.IsBodyHtml = true;

// send the message
client.Send(mm);
Classic ASP, Web

Check For A Referring Page URL And Redirect (Classic ASP)

I spent a while looking around for something that would help me tighten up some pages that did not need reached unless they came from another page that I had authorized.

In this example we check first that there is a referring URL and if there is not then go to my error page. The next part two checks look to ensure that the referring page is not the two pages we are okay with the referring URL to be.  If the referring URL is not either of those then we know the previous page is not what we want either and we refer to an error page.

<%
referer=request.servervariables("http_referer")
if (referer = "") then
Response.Redirect "error.asp"
elseif (referer <> "<a href="https://www.google.com">https://www.google.com</a>") then

elseif (referer <> "<a href="https://www.yahoo.com">https://www.yahoo.com</a>") then

else
Response.Redirect "error.asp"
end if
%>