git config –get remote.origin.url
Page 21 of 23
Git – Get and set the global user and email id
Checking the global user email and name-
git config –global user.email
git config –global user.name
To set the user details-
git config –global user.email “email@example.com”
git config –global user.name “user name”
If you also want to see Git workflow/ three tree architecture
Sitecore MediaFolder VS Media.FileFolder
Sitecore has 2 settings in the config named MediaFolder and Media.FileFolder, both has a different functionality.
MediaFolder – path used in this setting, Sitecore shall watch this folder for the files that need to be automatically uploaded to Sitecore media library. The path in this setting can be a Site path (e.g. /folder/) or a absolute path(e.g. C:\folder). The file path should be different from Media.FileFolder. By default it is set to /upload. So any files moved to this folder will be watched by Sitecore and uploaded media library.
Disable file watcher
There is a security aspect here, if you want to only enable the file upload using Sitecore client then disable the file upload watcher.
To ensure that only way to upload file is through Media Library disable the file watcher by removing the following line in web.config in
[code language=”xml”]
[/code]
Media.FileFolder – path used in the settings can be a Site path (e.g. /folder/) or a absolute path(e.g. C:\folder)
When media files are uploaded from Media Library as a file, the files are been uploaded into configured path in this settings. So this files are not saved in database instead reside in as a physical file on server or computer.

Sitecore media items vs media files
In Sitecore there is a difference between media item and media file.
A media item can be a image, a document or a video.
Media files are kept in a computer. Its when the file is uploaded to Sitecore a media item is created where the file is associated to the media item.
Media item can be –
1. Images
2. Videos
3. Documents including PDF
4. Audio files
The media item can be managed from the Media Library.
The variable ‘ex’ is declared but never used. How to suppress this error?
[code language=”csharp”]
catch (OutOfMemoryException ex)
{
Log.Error("Error")
}
[/code]
Severity Code Description Project File Line Suppression State
Error CS0168 The variable ‘ex’ is declared but never used
To suppress this code remove variable and simply write catch block like this-
[code language=”csharp”]
catch (OutOfMemoryException)
{
Log.Error("Error")
}
[/code]
Sitecore LiveMode.config
Sitecore Live Mode allows to run the site on content database i.e. master db rather then a web database or published content. This is useful for developers who tend to test the code without publishing Sitecore items every time it is changes in dev or local machine.
Live mode can be set in 2 ways-
- Directly changing in Sitecore.config or config where Site settings are patched. Set your site database element value to master.
- Set the LiveMode.config in /App_Config/Include folder
To setup the Sitecore.config, update following-
[code language=”xml”]
<sitecore>
<sites>
<site name="yoursitename" databasename="master" …></site>
</sites>
</sitecore>
[/code]
To setup LiveMode.config, update following-
[code language=”xml”]
<sitecore>
<sites>
<site name="yoursitename">
<patch:attribute name="database">master</patch:attribute>
<patch:attribute name="filterItems">true</patch:attribute>
<patch:attribute name="enableWorkflow">true</patch:attribute>
</site>
</sites>
</sitecore>
[/code]
database attribute to master for you site.
filteritems is set to true which means that items which has publishing restrictions will be filtered out. This is recommended to be true.
enableWorkflow – set this to false if the items that are in workflow and if you want to be seen in live mode.
nuget restore: Exception has been thrown by the target of an invocation
I am working on Sitecore 8.2 Helix based architecture. whilst doing a build received error –
MSBuild auto-detection: using msbuild version ‘14.0’ from ‘C:\Program Files (x86)\MSBuild\14.0\bin’
Error parsing solution file… Exception has been thrown by the target of an invocation.
Was able to resolve this issue suppose while merging changes the solution was missing the End Project
Project(…)
EndProject
Project(…)
Project(…)
EndProject
After adding the “EndProject” was able to parse the solution and build.
C# 7 Local Functions
C# 6 Local functions are useful to create helper methods and was written as below-
public class LocalFunctions
{
public int Age { get; set; }
public string C6PrivateFunction()
{
return $"C#6 ==> Person is {GetEligibility(Age)}";
}
}
private string GetEligibility(int age)
{
return age > 18 ? "Adult" : "Youth";
}
With C# 7.0 the same can be written as below.
Inside local functions, variables and parameters from the enclosing scope are also available and the same can also be written using as expression body.
public string C7LocalFunction()
{
return $"C#7 ==> Person is {GenerateEligibility(Age)}";
string GenerateEligibility(int age)
{
return age > 18 ? "Adult" : "Youth";
}
}
public string C7LocalFunction1()
{
return $"C#7 ==> Person is {GenerateEligibility(Age)}";
string GenerateEligibility(int age) => age > 18 ? "Adult" : "Youth";
}
Enjoy coding!!!
C# 7.0 – Throw expressions
C# 7.0 introduced throw expression, throwing exception has always been a statement and need to call a method to throw exception. Syntax is same as you’ve always used to throw exceptions difference is it can be also placed in the conditional expressions
With c# 7.0 exceptions can be thrown directly from within expression as shown below-
public class ThrowExpressions
{
public static string ThrowExpressionMethod(string someString)
{
return string.IsNullOrWhiteSpace(someString) ? throw new ArgumentNullException("someString is empty") : someString;
}
}
C# 7.0 Numerical literals and OUT variables
Numeric literal syntax
Reading numbers makes it difficult to understand code. C# 7 has improvement done on the digit separator.
public static int IntegerLiterals()
{ return 1_000_000; }
public static double DoubleLiterals()
{ return 9_8_7.1_2_3; }
public static int BinaryLiterals()
{ return 0b0001_0000; }
Console.WriteLine($" One Million : {NumericalLiterals.IntegerLiterals()}");
Console.WriteLine($" Double : {NumericalLiterals.DoubleLiterals()}");
Console.WriteLine($" Binary to Decimal : {NumericalLiterals.BinaryLiterals()}");
Output:
One Million : 1000000
Double : 987.123
Binary to Decimal : 16
Inline out variables
Earlier declaring out variables has to be done separately. Now this can be done in line as follows
public static int InlineOutVariables()
{
string input = "100";
if (!int.TryParse(input, out int result))
{
return 0;
}
return result;
}
You can declare out variable where you use it. The declared out variables also leaks out of the if statement scope and used later.




