Skip to content

Instantly share code, notes, and snippets.

@karlitros
karlitros / RefreshDocument.cs
Created June 28, 2012 08:06
A fix to allow document urls to update in the Umbraco back office after moving a document programmatically
//newParentFolderId = the parentId you want to move the document to
//documentObject = the document you're moving to its new location.
documentObject.Move(newParentFolderId);
if (!autoFolder.EnableBatchProcessing)
{
library.RefreshContent();
documentObject.Publish(new User(0));
@karlitros
karlitros / global-snippet.asax.cs
Created June 20, 2012 10:24
Avoiding duplicate content due to case-sensitive URLs
protected void Application_BeginRequest(object sender, EventArgs e)
{
//If upper case letters are found in the URL, redirect to lower case URL.
if (Regex.IsMatch(HttpContext.Current.Request.RawUrl.ToString(), @"[A-Z]") == true)
{
if (Request.HttpMethod == "GET" && !(Request.RawUrl.Contains(".axd")))
{
string LowercaseURL = HttpContext.Current.Request.RawUrl.ToString().ToLower();
Response.Clear();
Response.Status = "301 Moved Permanently";
@karlitros
karlitros / OpenPop.cs
Created June 19, 2012 16:15
OpenPOP source code for fetching email from a POP server
OpenPOP.POP3.POPClient client = new POPClient("pop.yourserver.co.uk", 110, "[email protected]", "password_goes_here", AuthenticationMethod.USERPASS);
if (client.Connected) {
int msgCount = client.GetMessageCount();
/* Cycle through messages */
for (int x = 0; x < msgCount; x++)
{
OpenPOP.MIMEParser.Message msg = client.GetMessage(x, false);