Enable IIS Failed Request Tracing

Step 1: Enable windows feature :  Internet Information Services >  World Wide Web Services  > Health and Diagnostic > Tracing

Step 2: Open IIS Manage > Go to your site >  click 'Failed Request Tracing...’ on actions pane > Click 'enable'.

Step 3: In the features view, click 'Failed request tracing rules'.  Click add and choose your purpose like below :

a : Selected ‘All Content (*)’ , Status Code(s) : 200 

b:  Selected ‘ASP.NET (*.aspx) , Staus Code(s) : 401-999 , Event severity : Error

c:  Selected ‘Custome : *.js’ , Status Code(s) : 200

Step 4 : Look in c:\inetpub\logs\FailedReqLogFiles\w3svcX\

Enable USB debugging on android 4.2.X

1. Settings -> About Phone and scroll to the end

2. Tap on “Build Number” for 7 times.

3. Settings ->  Developer Option appear on your setting list now.

Check USB debugging > Ok

JavaScript add bookmark

無法查看此摘要。請 按這裡查看文章。

Windows command – backup & remove all IIS log

  1. Download Source code by package (must) ,  Unzip BackupLog Folder to C:\  (Total 5 files: 7z.dll , 7z.exe , ufind.exe,  BackupLog.bak, BackupLog_Chinese.bak)
  2. Download sample batch (must) based on date and time format.  US or Chinese
    Chinese format , US Format
  3. Check your IIS Log path location was under the “C:\inetpub\logs\LogFiles”  , if not please modify sample batch or modify the parameter whatever you want.
  4. [Option] Setting task scheduler run the batch file
Dropbox share link OR Download Source code by package

A Friendly remind: If choose task scheduler to perform batch job, please ensure the account log-in on the server once and had permission on log folder.

[Umbraco] Replace p tags start with root block in TinyMCE Editor

Purpose : Replace <p> to <div>+<br/>

Version: 4.X   ,   File : /config/tinyMceConfig.config

Add TinyMCE configuration key under the <customConfig> element.

<config key="force_p_newlines">false</config>
<config key="force_br_newlines">true</config>    
<config key="forced_root_block">div</config>   

Recycle Application pool.

[Umbraco] Bug in calculating image dimensions in TinyMCE

Encounter in version  4.5.2 & 4.7.1

Update one existing picture by TinyMCE , when change height or width , another one will be changes to NaN.

How to fix:

Add rel in allowedAttributes element

File : /config/umbracoSetting.config

<allowedAttributes>alt,title,border,class,style,align,id,name,onclick,usemap,rel</allowedAttributes>

2. Ensure img element allw rel attribute ,

File : /config/tinyMCEConfig.config

img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align|umbracoorgwidth|umbracoorgheight|onresize|onresizestart|onresizeend|rel],

[Umbraco] Add User with hashed password & check unique loginname

protected static bool addUmbracoUser(string loginName, string userName, string password)
{
if (ensureUniqueLoginName(account))
{
User u = umbraco.BusinessLogic.User.MakeNew(userName, loginName.Trim(), hashPassword(password), new List < UserType> ());
u.addApplication("content");
u.addApplication("media");
u.addApplication("users");
u.addApplication("settings");
u.addApplication("developer");
u.addApplication("members");
u.Save();
return true;
}
else
{ return false; }
}

private static bool ensureUniqueLoginName(string loginName)
{
umbraco.BusinessLogic.User[] u = umbraco.BusinessLogic.User.getAllByLoginName(loginName);
if (u.Length != 0)
{
return false;
}
return true;
}

private static string hashPassword(string password)
{
HMACSHA1 hash = new HMACSHA1();
hash.Key = Encoding.Unicode.GetBytes(password);

string encodedPassword = Convert.ToBase64String(hash.ComputeHash(Encoding.Unicode.GetBytes(password)));
return encodedPassword;
}


Reference: http://our.umbraco.org/wiki/reference/api-cheatsheet/users,-user-types-and-permissions/add-user-with-hashed-password