Geeks With Blogs
Sharvan Dhaka blog
X509Chain Class
Namespace: System.Security.Cryptograph... System (in system.dll) The X509Chain object has a global error status called ChainStatus that should be used for certificate validation. The rules governing certificate validation are complex, and it is easy to oversimplify the validation logic by ignoring the error status of one or more of the elements involved. The global error status takes into consideration the status of each element in the chain.The following code example opens ......

Posted On Sunday, October 15, 2006 6:18 PM

Digital Certification X509Certificate C#
Any application of cryptography in building a secured infrastructure uses many of encryption, hashing and signature ciphers. In fact all the cryptographic solutions that are available today include a comprehensive infrastructure with many ciphers, extensive security policies, rich tools for creating, deploying and managing secure applications and other integrated set of cryptographic services. One such infrastructure that comes with Windows 2000 is Public Key Infrastructure (PKI). The challenge for ......

Posted On Sunday, October 15, 2006 6:12 PM

Read Response of a web request in a byte Array with C#
this code snippet read the respone fo a web request through binary reader private byte[] getByte(string URL) { HttpWebRequest wrGETURL = (HttpWebRequest)WebRequest.... System.Net.HttpWebResponse webresponse = (HttpWebResponse)wrGETURL.G... string ct = webresponse.ContentType; Stream objStream = webresponse.GetResponseStre... BinaryReader breader = new BinaryReader(objStream); byte[] buffer = breader .ReadBytes((int)webresponse... return buffer; } ......

Posted On Sunday, October 15, 2006 5:57 PM

Force a page to download a file c#
string Id= "0"; try { this.EnableViewState = false; Response.ContentType = "text/.txt"; string Filename = System.Web.HttpContext.Curr... Filename = Filename + Id + ".txt"; Response.WriteFile(Filename); // Response.Write("string"); string strFilename = Id + ".txt"; Response.Buffer = true; Response.AddHeader("Content... "attachment; filename=" + ID+".txt"); } catch (Exception ex) { Response.Write(ex.ToString()); } Response.End(); ......

Posted On Sunday, October 15, 2006 5:56 PM

Create .VCF File(outlook contact file) with C#
This is code of to create vcf card on the fly //sdBuild is string builder sdBuild.Append("N:" + strCn + System.Environment.NewLine); sdBuild.Append("FN:" + strCn +System.Environment.NewLine); //// encoding to base 64 certString64 = certString64 + System.Environment.NewLine + "KEY;X509;ENCODING=BASE64:" + System.Environment.NewLine; certString64 = certString64 + Convert.ToBase64String((byt... + System.Environment.NewLine; //// encoding to base 64 ends here sdBuild.Append(certString64); sdBuild.Append(System.Envir... ......

Posted On Sunday, October 15, 2006 5:55 PM

How to get the HTML name attribute of ASP.Net Control c#
//Function to get the HTML name of the server control from the Client Id // Parameters: // clientId - Control.ClientId // serverId - private string GetHTMLNameById(string clientId, string serverId) { int pos = serverId.IndexOf('_'); string HTMLName = ""; if(pos >= 0) { pos = clientId.IndexOf(serverId); HTMLName = clientId.Remove(pos, serverId.Length); HTMLName = HTMLName.Replace('_', '$'); HTMLName += serverId; } else HTMLName = clientId.Replace('_', '$'); return HTMLName; } ......

Posted On Sunday, October 15, 2006 5:49 PM

Serialize & Deserialize c#
Serialize (convert an object instance to an XML document): // Assuming obj is an instance of an object XmlSerializer ser = new XmlSerializer(obj.GetType()); System.Text.StringBuilder sb = new System.Text.StringBuilder(); System.IO.StringWriter writer = new System.IO.StringWriter(sb); ser.Serialize(writer, obj); XmlDocument doc = new XmlDocument(); doc.LoadXml(sb.ToString()); Deserialize (convert an XML document into an object instance): //Assuming doc is an XML document containing a serialized object ......

Posted On Sunday, October 15, 2006 5:43 PM

How to convert a string to a byte array and convert a byte array to a string c#
Convert a string to a byte array string myString = "a test string"; byte[] myByteArray = new byte[myString.Length]; int i = 0; foreach(char c in InStr.ToCharArray()) { myByteArray [i] = (byte)c; i++; } Convert a byte array to a string System.Text.Encoding enc = System.Text.Encoding.ASCII; byte[] myByteArray = enc.GetBytes("a text string); string myString = enc.GetString(myByteArray ); ......

Posted On Sunday, October 15, 2006 5:42 PM

Diff DataReader/DataAdapter
The DataReader provides forward, read-only access to the data read from the database. It provides no mechanisms for randomly accessing the data. A DataAdapter, along with a DataTable or DataSet, provides random access to data. In addition, the data can be changed in the DataTable or DataSet, and the DataAdapter can be used to update the data in the database. Of the two access methods, the DataReader is the lightest and fastest and is preferable when you need to only read the data, as reflected in ......

Posted On Sunday, October 15, 2006 5:38 PM

Preventing Multiple Logins in ASP.NET
We talked about the fact that the classic ASP Session_OnEnd handler is widely known to be pretty unreliable. However, in ASP.NET the corresponding Global class handler, Session_End, is very reliable. Then we talked about "what if" scenarios, such as what if the ASP.NET worker process was recycled? If so, I reasoned, it didn't matter whether you were using Session, Application or Cache, all of your stuff would be lost. The only exceptions to this would be if you were using the ASP.NET State Server ......

Posted On Sunday, October 15, 2006 5:36 PM

Resize popup to image size
This script is used to Resize the Popup as per the Image dimensions.

Posted On Sunday, October 15, 2006 5:32 PM

HOW TO: Configure SQL Server Security for .NET Applications
This article describes how to configure the SQL Server for .NET applications. By default, the SQL Server denies access to user accounts that have not explicitly been granted access to a database, a table, or a view. By default, ASP.NET applications run in the context of the ASPNET user account. Unless you permit access to the ASPNET user account, an ASP.NET application cannot read and cannot update data in an SQL Server database. This article describes the process that you can use to permit an ASP.NET ......

Posted On Sunday, October 15, 2006 4:59 PM

Url Rewriting
<div class="post-body"><p&... style="CLEAR: both"></div><span style="color:#ff0000;">&... Sample </strong> </span> string StrFilePath = Request.FilePath; int intStart = StrFilePath.LastIndexOf("/") + 1 ; int intEnd = StrFilePath.LastIndexOf(".a... int intLength = intEnd - intStart; //CHECK THE URL STRING FOR USER SUB DIRECTORY if(intEnd&gt;0 &amp;& intStart&gt;0) { StrFilePath = StrFilePath.Substring(intSt... ......

Posted On Sunday, October 15, 2006 4:15 PM

Partial Classes in ASP.NET
Partial class is a new functionality that is included in Visual Studio .Net 2005 and is supported in ASP.Net 2.0. This new functionality helps you to split a single class into multiple partial classes. These partial classes can be in different individual files. In the earlier versions of Visual Studio .Net 2005, while you create an ASP.Net application, you might have seen that a single class has to be in a single file. You will be beginning a class and ending that class in the same file. It was not ......

Posted On Sunday, October 15, 2006 4:14 PM

Access to the path containing 'hash.web' is getting denied.
After installing Visual Studio .NET and F5 a couple of times, I used to get this error frequently. The only resolution was to wait for upto 5 to10 mins or restart system, since a folder in Temporary ASP.NET files containing web.config gets locked up automatically. After searching a while in KBs, Forums, I found one closest matching solution, which solved my problem. Just wanted to share with other readers who would also be experiencing this issue. The problem occurs significantly if you touch web.config ......

Posted On Sunday, October 15, 2006 4:12 PM

Copyright © Sharvan Dhaka | Powered by: