Sunday, December 6, 2015

How to set default page in umbraco?


Setting default page is a tricky process, as umbraco always defaults to the first page in document structure. Sometimes, the first page in your document structure may not be the default document you. In such case you can use the below approach.

 

In the template of the first document (or create new document type for tis and use this for creating a root document), add java script redirection as below .In my case it will redirect to index.html.

 

Tuesday, December 1, 2015

How to pre compile a website using aspnet_compiler?

Just use the below command to precompile your website

 

aspnet_compiler -p physicalOrRelativePath -v / targetPath

 

More information regarding the same can be found here


How to Delete/Rebuild Umbraco cache?





How to Delete/Rebuild Umbraco cache?
 


Umbraco maintains the content in two places. One in database and the other in file system as cache in xml. The file system (cache version) can be cleared by hitting at the below link.

Delete/Rebuild umbraco based website cache from direct url:
http://&ltYoursitename>/Umbraco/dialogs/republish.aspx?xml=true

 
If you need further information, the same can be found here







Saturday, November 28, 2015

How does href attribute of anchor tags works?

I Just found the following site that I think does a really good job explaining the href attribute of anchor tags and how it interprets URL paths.  It shows a lots of examples to illustrate the differences between the path types:


http://www.mediacollege.com/internet/html/hyperlinks.html

Thursday, February 26, 2015

How to force a query to recompile every time in SQL server.

If you want to clear execution plan and cache, you could use the below commands

DBCC FreeProcCache
DBCC DropCleanbuffers


More details here
https://msdn.microsoft.com/en-us/library/ms174283.aspx

If you want to force query compilation each time, just add the below to the end of the query

OPTION (RECOMPILE)

Thursday, December 11, 2014

How to recursively remove a file type under a folder using PowerShell?


The below PowerShell code will help you to recursively find the files from a folder and remove it

The second line will recursively make the files in folder not rad only


$checkoutLocation = "D:\Develop\VSS\Vb"
# Removed the file recursively
Get-ChildItem -Path $checkoutLocation -Filter *.scc -Recurse | Remove-Item -Force

# Makes file not read-only recursively
Get-ChildItem -Path $checkoutLocation -Recurse | ForEach-Object { if ($_.IsReadOnly) { $_.IsReadOnly = $false } }

Monday, November 24, 2014

Why SQL server some times silently truncate the values you passed to a column and some time errors

Scenario

There are scenarios when SQL server silently truncate the values you passed to a column and sometime error as below. Actually what is happening behind the seen here?

Msg 8152, Level 16, State 14, Line 2
String or binary data would be truncated.
The statement has been terminated.

Let’s explore…….

The magic here is because of ANSI_WARNINGS begin set to OFF

In normal circumstances SQL server will truncate the data passed with respect to the underlying column if ANSI_WARNINGS is set to OFF. In case of ANSI_WARNINGS set to ON will result in the above error.

But this is overridden in case you are passing data through a variable. For example assume you have an underlying column of varchar(50) and you declare a variable varchar(50). If you try to assign the variable with a string having length greater than 50 then SQL server will automatically truncate the same to 50 with without popping any error irrespective of ANSI_WARNINGS OFF or ON.

But the above can result in an error if you are declaring the variable as varchar (40) for underling varchar (50) column.

Note: This truncation can also happen in .net before hitting to SQL server if you have explicitly declared the size of SQL parameter

For example:
comm.Parameters.Add("@Name", System.Data.SqlDbType.NVarChar, 50);
comm.Parameters["@Name"].Value = Name;