Sunday, January 31, 2010
Thursday, January 28, 2010
Wednesday, January 27, 2010
Facebook Connect
http://wiki.developers.facebook.com/index.php/Facebook_Connect
http://wiki.developers.facebook.com/index.php/Getting_Started_with_Facebook_Connect
http://wiki.developers.facebook.com/index.php/How_To_Write_A_Good_Connect_App
http://wiki.developers.facebook.com/index.php/How_Connect_Interacts_with_the_Facebook_API
http://wiki.developers.facebook.com/index.php/Getting_Started_with_Facebook_Connect
http://wiki.developers.facebook.com/index.php/How_To_Write_A_Good_Connect_App
http://wiki.developers.facebook.com/index.php/How_Connect_Interacts_with_the_Facebook_API
Disable ?returnUrl for ASP.net Membership
After users pass the Basic Authentication, the url appends the ?returnUrl=login.aspx. And this redirects the user to login page after they logged in.
Here are two posts that can solve the problem.
1. Call Response.redirect to the destination URL:
http://www.velocityreviews.com/forums/t367373-remove-returnurl-from-url.html
2. Remove the returnUrl part in the login page:
http://ordinastage.blogspot.com/2007/05/aspnet-membership-returnurl-problem.html
Here are two posts that can solve the problem.
1. Call Response.redirect to the destination URL:
http://www.velocityreviews.com/forums/t367373-remove-returnurl-from-url.html
2. Remove the returnUrl part in the login page:
http://ordinastage.blogspot.com/2007/05/aspnet-membership-returnurl-problem.html
Tuesday, January 26, 2010
Secure HTTP cookie
If you are using SSL with your site, which you must in order to use an SSL cookie, then add the following line in your web.config, inside the <system.web> tag:
<httpCookies httpOnlyCookies="false" requireSSL="true" />
http://forums.asp.net/p/1242647/2275159.aspx#2275159
<httpCookies httpOnlyCookies="false" requireSSL="true" />
http://forums.asp.net/p/1242647/2275159.aspx#2275159
Single Sign-On Enterprise Security for Web Applications
Single Sign-On Enterprise Security for Web Applications
http://msdn.microsoft.com/en-us/library/ms972971.aspx
http://msdn.microsoft.com/en-us/library/ms972971.aspx
Monday, January 25, 2010
Thursday, January 21, 2010
OpenSta Tutorial
1. Declare variables first
CHARACTER*512 fileuser, FILE = "user", SCRIPT
CHARACTER*512 filepassword, FILE = "password", SCRIPT
CHARACTER*512 fileaccountno, FILE = "accountno", SCRIPT
CHARACTER*100 currentUsername, LOCAL
CHARACTER*100 currentPassword, LOCAL
CHARACTER*100 currentAccountNo, LOCAL
2. Tell when it should use the new variables
ACQUIRE MUTEX "Login"
NEXT fileuser
NEXT filepassword
NEXT fileaccountno
SET currentusername = fileuser
SET currentpassword = filepassword
SET currentaccountno = fileaccountno
RELEASE MUTEX "Login"
3. Replace the previously recorded info with the new variables.
4. Create new files (.fvr, e.g. user.fvr, password.fvr, accountno.fvr in this case)
Each line in the file represent one record (line break to separate it).
and place them in C:\Program Files\OpenSTA\Repository\Data
5. Create a new Test and drag the script in the task view.
6. Set the VU (Total number of virtual users for this task group)
CHARACTER*512 fileuser, FILE = "user", SCRIPT
CHARACTER*512 filepassword, FILE = "password", SCRIPT
CHARACTER*512 fileaccountno, FILE = "accountno", SCRIPT
CHARACTER*100 currentUsername, LOCAL
CHARACTER*100 currentPassword, LOCAL
CHARACTER*100 currentAccountNo, LOCAL
2. Tell when it should use the new variables
ACQUIRE MUTEX "Login"
NEXT fileuser
NEXT filepassword
NEXT fileaccountno
SET currentusername = fileuser
SET currentpassword = filepassword
SET currentaccountno = fileaccountno
RELEASE MUTEX "Login"
3. Replace the previously recorded info with the new variables.
4. Create new files (.fvr, e.g. user.fvr, password.fvr, accountno.fvr in this case)
Each line in the file represent one record (line break to separate it).
and place them in C:\Program Files\OpenSTA\Repository\Data
5. Create a new Test and drag the script in the task view.
6. Set the VU (Total number of virtual users for this task group)
Error: The located assembly's manifest definition does not match the assembly reference.
Today's error:
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Wednesday, January 20, 2010
3DES
3DES 128 bit encryption does not exist
http://superconductor.voltage.com/2009/04/3des-128-bit-encryption.html
http://superconductor.voltage.com/2009/04/3des-128-bit-encryption.html
Friday, January 15, 2010
Thursday, January 14, 2010
Javascript email Regex
var email = "^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$";
Wednesday, January 13, 2010
Tuesday, January 12, 2010
301 redirect using IIS
To 301 redirect in IIS from http:// to https://,
1. Setup another site and set TCP port to 80 (original site uses other value).
2. Under "Home Directory",
Select "A redirection to a URL",
In Redirect to, type "https://www.example.com$S$Q
3. Check "The exact URL entered above" and "A Permanent redirection for this resource".
1. Setup another site and set TCP port to 80 (original site uses other value).
2. Under "Home Directory",
Select "A redirection to a URL",
In Redirect to, type "https://www.example.com$S$Q
3. Check "The exact URL entered above" and "A Permanent redirection for this resource".
Generate a CSV from a generic list of objects using reflection and extension methods
http://www.joe-stevens.com/2009/08/03/generate-a-csv-from-a-generic-list-of-objects-using-reflection-and-extension-methods/
using System.Text;
using System.Reflection;
public static class Extensions
{
public static string GetCSV(this List list)
{
StringBuilder sb = new StringBuilder();
//Get the properties for type T for the headers
PropertyInfo[] propInfos = typeof(T).GetProperties();
for (int i = 0; i <= propInfos.Length - 1; i++)
{
sb.Append(propInfos[i].Name);
if (i < propInfos.Length - 1)
{
sb.Append(",");
}
}
sb.AppendLine();
//Loop through the collection, then the properties and add the values
for (int i = 0; i <= list.Count - 1; i++)
{
T item = list[i];
for (int j = 0; j <= propInfos.Length - 1; j++)
{
object o = item.GetType().GetProperty(propInfos[j].Name).GetValue(item, null);
if (o != null)
{
string value = o.ToString();
//Check if the value contans a comma and place it in quotes if so
if (value.Contains(","))
{
value = string.Concat("\"", value, "\"");
}
//Replace any \r or \n special characters from a new line with a space
if (value.Contains("\r"))
{
value = value.Replace("\r", " ");
}
if (value.Contains("\n"))
{
value = value.Replace("\n", " ");
}
sb.Append(value);
}
if (j < propInfos.Length - 1)
{
sb.Append(",");
}
}
sb.AppendLine();
}
return sb.ToString();
}
}
Monday, January 11, 2010
Avoid concurrent login (logout former login session) in ASP.net membership
In login.aspx:
protected void Login1_LoggedIn(object sender, EventArgs e)
{
string sKey = Login1.UserName;
string sValue = Session.SessionID;
Session[sKey] = sValue;
TimeSpan SessTimeOut = new TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0);
HttpContext.Current.Cache.Insert(sKey, sValue, null, DateTime.MaxValue, SessTimeOut,
System.Web.Caching.CacheItemPriority.NotRemovable, null);
}
In Master Page of admin:
protected void Page_Load(object sender, EventArgs e)
{
string sValue = Cache[HttpContext.Current.User.Identity.Name].ToString();
if (Session.SessionID != sValue)
{
FormsAuthentication.SignOut();
Response.Redirect("login.aspx");
}
}
http://stackoverflow.com/questions/2025908/avoid-concurrent-login-logout-former-login-session-in-asp-net-membership
protected void Login1_LoggedIn(object sender, EventArgs e)
{
string sKey = Login1.UserName;
string sValue = Session.SessionID;
Session[sKey] = sValue;
TimeSpan SessTimeOut = new TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0);
HttpContext.Current.Cache.Insert(sKey, sValue, null, DateTime.MaxValue, SessTimeOut,
System.Web.Caching.CacheItemPriority.NotRemovable, null);
}
In Master Page of admin:
protected void Page_Load(object sender, EventArgs e)
{
string sValue = Cache[HttpContext.Current.User.Identity.Name].ToString();
if (Session.SessionID != sValue)
{
FormsAuthentication.SignOut();
Response.Redirect("login.aspx");
}
}
http://stackoverflow.com/questions/2025908/avoid-concurrent-login-logout-former-login-session-in-asp-net-membership
Thursday, January 7, 2010
Monday, January 4, 2010
Hash and Encryption
Hash
Hash is 1 way which cannot be decrypted.
Hash method:
1. MD5
2. SHA1
http://dotnetpulse.blogspot.com/2007/12/sha1-hash-calculation-in-c.html
http://www.obviex.com/samples/hash.aspx
http://stackoverflow.com/questions/1454747/how-to-decrypt-md5-or-sha1-is-it-possible
Encryption
Encryption is 2 way and can be decrypted.
Encryption method:
1. TripleDES
2. Rijndael
Rainbow Table
http://en.wikipedia.org/wiki/Rainbow_table
Salt
http://en.wikipedia.org/wiki/Salt_%28cryptography%29
Hash is 1 way which cannot be decrypted.
Hash method:
1. MD5
2. SHA1
http://dotnetpulse.blogspot.com/2007/12/sha1-hash-calculation-in-c.html
http://www.obviex.com/samples/hash.aspx
http://stackoverflow.com/questions/1454747/how-to-decrypt-md5-or-sha1-is-it-possible
Encryption
Encryption is 2 way and can be decrypted.
Encryption method:
1. TripleDES
2. Rijndael
Rainbow Table
http://en.wikipedia.org/wiki/Rainbow_table
Salt
http://en.wikipedia.org/wiki/Salt_%28cryptography%29
Friday, January 1, 2010
Subscribe to:
Posts (Atom)