Tuesday, January 26, 2010

Firefox plugin Tamper Data

https://addons.mozilla.org/en-US/firefox/addon/966

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

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

Thursday, January 21, 2010

Block cipher modes of operation

http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation

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)

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)

Wednesday, January 20, 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})$";

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".

Web Design From Scratch

http://webdesignfromscratch.com/

http://office.microsoft.com/en-us/frontpage/HA011671221033.aspx

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