[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

RadControls – RadGrid export to Excel with text format


void btnExport_Click(object sender, ImageClickEventArgs e)
{
rgGrid.ExcelExportCellFormatting += new OnExcelExportCellFormattingEventHandler(rgKBuser_ExcelExportCellFormatting);
rgGrid.MasterTableView.ExportToExcel();

}
void rgKBuser_ExcelExportCellFormatting(object sender, ExcelExportCellFormattingEventArgs e)
{
e.Cell.Style["mso-number-format"] = @"\@";
}

Reference: http://www.telerik.com/help/aspnet-ajax/grid-html-export.html

Security issue – HttpResponse.Redirect in Umbraco appear trace information


If use below solution to implement redirection on your site.
Please ensure hack ~/default.aspx to disable the trace parameter.
<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="True" Inherits="umbraco.UmbracoDefault" trace="false" validateRequest="false" %>
Please use web debugging tool to check your umbraco site , e.g. Fiddler
You can fellow below step .
1. open Fiddler
2. visit the redirect URL .  
3. in WebView tab , will appear all trace information , like Server Variables , Session State

IIS 7 To export/import a single website

Step1 Export:
%windir%\system32\inetsrv\appcmd list site “MyWebsite” /config /xml > c:\mywebsite.xml

Step2 Hack xml:
Hack name & id attributes in second site element , c:\mywebsite.xml

e.g.
<site name="mywebsite" id="1" serverAutoStart="true">
to
<site name="mywebsite2" id="2" serverAutoStart="true">

Step3 Import:
%windir%\system32\inetsrv\appcmd add site /in < c:\mywebsite.xml

Reference: :http://www.microsoftpro.nl/2011/01/27/exporting-and-importing-sites-and-app-pools-from-iis-7-and-7-5/


Note for purpose of create new website and keep original website

  1. Manually add new application pool & set new applicationPool to your website.
  2. Set attribute of serverAutoStart to “false”
  3. Set new attribute to bindingInformation.