Friday, July 1, 2011

difference between design pattern and architecture?

1) A design pattern is a set of techniques or a methodology for writing your code. I tend to think of design patterns as named coding tips/tricks on how you write you code. Patterns are a very well thought out ways of solving a coding problem. I say named because each pattern has a name. The reason that they are named is that everyone discussing how to implement the code knows what you mean when you say your coding something using the Observer or factory pattern.

An architecture on the other hand are the different parts of the application and how they fit together. For instance, the UI might be part of the architecture. If your using a webservice that might be part of the architecture.

Architecture comprises the frameworks, tools, programming paradigms, component-based software engineering standards, design principles.
2)


if you are using both terms, then Architecture encompasses more technical or structural decisions about how to build or construct something, especially those decisions that will be hard (or harder) to change once implemented, whereas Design encompasses those decisions that either are easy to change later (like method names, class <-> file organizational structure, design patterns, whether to use a singleton or a static class to solve some specific problem, etc. ) and/or those that effect the appearance or esthetic aspects of a system or application (Human Interface, ease of use, look and feel, etc.)

Wednesday, October 13, 2010

How to create IIS Log [IIS 6.0]

1. Open [Internet Services Manager]

2. For [Default Web Site], Right click and open [Properties]

3. In the tab, [Web Site], enable the checkbox [Enable Logging]

4. Select [Active Log Format] as [W3C Extended Log File Format]

5. Click on the button [Properties]

6. In the [General Properties] tab, select [Daily] for [New Log Time Period]

7. In the [Extended Properties] tab, select the following fields

I. date

II. time

III. s-sitename

IV. s-computername

V. s-ip

VI. cs-method

VII. cs-uri-stem

VIII. cs-uri-query

IX. s-port

X. cs-username

XI. c-ip

XII. cs-version

XIII. cs(User-Agent)

XIV. cs(Cookie)

XV. cs(Referer)

XVI. cs-host

XVII. sc-status

XVIII. sc-substatus

XIX. sc-win32-status

XX. sc-bytes

XXI. cs-bytes

XXII. 22. time-taken

8. Apply the configuration changes

Monday, March 1, 2010

Browser detection using JavaScript

Browser detection allows you to find out what browser your viewer is using .

There are two objects often used for this,

1.navigator.appName

2.navigator.appVersion

The first one returns the name of the browser, the second returns the version of the browser.

ex:
function aa()
{
var browserName=navigator.appName;
if (browserName=="Netscape")
{
alert("Netscape User");
}
else
{
if (browserName=="Microsoft Internet Explorer")
{
alert("InterNet Explorer User");
}
else
{
alert("Other browser User");
}
}
}

Friday, February 19, 2010

MD5 Hashing In C#

using System;
using System.Security.Cryptography;
using System.Text;

MD5 md5 = MD5.Create();
byte[] data = md5.ComputeHash(Encoding.Default.GetBytes("neeraj"));
StringBuilder s_builder = new StringBuilder();
foreach (byte b in data)
{
s_builder.Append(b.ToString("x2"));
}

Response.Write(s_builder);

Wednesday, October 7, 2009

MAC-Based Authentication for Web Sites using C#

using SHDocVw;
using mshtml;

String url = "YourWebSite.com/login.aspx";
IHTMLElementCollection htmlCollection;
HTMLDocument html;
HTMLInputElement htmlInput;
object obj = null;
InternetExplorer ie=new InternetExplorer();
ie.Navigate(url,ref obj,ref obj,ref obj,ref obj);
while (ie.Busy)
{
Application.DoEvents();
}
html =(HTMLDocument)ie.Document;
ie.Visible = true;
htmlCollection= html.getElementsByTagName("input");

foreach(HTMLInputElement input in htmlCollection)
{
if (input.name == "txtUserName") //txtUserName is your login.aspx page text control
input.innerText = "mylogin"; // assign username in login.aspx page
if (input.name == "txtPassword") //txtPassword is your login.aspx page text control
input.innerText = "mypassword"; //assign password in login.aspx page
if (input.name == "txtMACAddress") //txtMACAddress is your login.aspx text control
input.innerText = "00:00:11:22:33:55"; //assign macAddress in login page
}
while (ie.Busy)
{
Application.DoEvents();
}
htmlCollection = html.getElementsByTagName("input");
foreach (HTMLButtonElement btn in htmlCollection)
{
if (btn.name == "btnLogin")
btn.click();

}
while (ie.Busy)
{
Application.DoEvents();
}


Note: Add "following reference in your Application
1) Add Reference --> Browse --> .System32(search inside windows folder) -->SHDocVw.exe
2) Add Reference --> .Net --> Microsoft.mshtml
Note: To get MAC address of machine please ref Article "http://code4developer.blogspot.com/2009/09/get-mac-address-of-client-machine-using.html"

How to get executable file information in C#

using System.IO;

string executableName = Application.ExecutablePath;
MessageBox.Show(executableName);
FileInfo executableFileInfo = new FileInfo(executableName);
string executableDirectoryName = executableFileInfo.DirectoryName;
MessageBox.Show(executableDirectoryName);

Friday, September 18, 2009

Get MAC address of client machine using C#

using System.Management;

String query = "select MacAddress FROM Win32_NetworkAdapter";
ObjectQuery objQuery = new ObjectQuery(query);
ManagementObjectSearcher moSearcher = new ManagementObjectSearcher(objQuery);
string macAddress = string.Empty;
foreach (ManagementObject obj in moSearcher.Get())
{
if(macAddress==string.Empty){
macAddress = obj["MACAddress"].ToString();
obj.Dispose();
}
}
MessageBox.Show(macAddress.ToString());

Note: Add System.Management in reference
(
Solution Explorer --> Add Reference --> .NET --> System.Management )