Programming

Move Umbraco 7.x from root website to virtual directory

Common issues:

1. Images stored in media folder is not loading.

2. CSS is not loading

3. JS is not loading

Resolution:

1. Open umbracoSettings.config in Config folder, add “<ResolveUrlsFromTextString>true</ResolveUrlsFromTextString>” in “<content>” section.

e.g.

<content>

<UmbracoLibraryCacheDuration>1</UmbracoLibraryCacheDuration>

<ResolveUrlsFromTextString>true</ResolveUrlsFromTextString>

</content>

2. Open umbraco CMS database, update table “cmsPropertyData” to fix the media path.

UPDATE cmsPropertyData set dataNvarchar = replace(dataNvarchar, ‘/media/’,’/<virdir>/media/’)

where dataNvarchar like ‘/media/%’

3. Re-published entire website to refresh the umbraco.config cache.

clip_image002

4. Re-publish each pages if point 3 does not work.

5. Update necessary template/ layout files.

Update JS & CSS path from "/js/*" to "~/js/*" and "/css/*" to "~/css/*"

image

6. IISRESET

Programming

C#, Export binary data to file from MS Sql Server Database Table

 

SqlConnection connection = new SqlConnection("server=x1;uid=x2;pwd=x3;database=x4;");
connection.Open();
// Select binary data from db
SqlCommand command = new
  SqlCommand("select Filename, Attachment, Convert(nvarchar(5), ID) + ‘_’ + Filename as NewFilename   from MyAttachments", connection);
SqlDataReader sqlDr = command.ExecuteReader();
while (sqlDr.Read())
{
    string filename = sqlDr.GetString(0);
    byte[] attachment = (byte[])sqlDr.GetValue(1);
    string newFilename = sqlDr.GetString(2);
    FileStream fs = new FileStream(@"D:\B2F\" + newFilename, FileMode.Create);
    fs.Write(attachment, 0, attachment.Length);
    fs.Close();

}

connection.Close();

Programming

Future directions for C# and Visual Basic

image

imageimage

Summary:
• C# and VB deeply support the Windows Runtime (Developing Metro Style App)
• C# and VB make asynchronous programming easy
• You can create hybrid C#/VB and JavaScript apps
• Visual Studio Roslyn CTP will be available soon (Oct 2011)
    – Copy in C# Paste in VB, Copy in VB Paste in C#
    – Execute code runtime, compile & run dynamically