Welcome to my blog.

Post on this blog are my experience which I like to share. This blog is completely about sharing my experience and solving others query. So my humble request would be share you queries to me, who knows... maybe I can come up with a solution...
It is good know :-)

Use my contact details below to get directly in touch with me.
Gmail: nadarmuthukumar1987@gmail.com
Yahoo: nadarmuthukumar@yahoo.co.in

Apart from above people can share their queries on programming related stuff also. As me myself a programmer ;-)

This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms

Actually, this issue is not caused by IIS, the problem occurs when the following conditions are true:
  • The HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\fipsalgorithmpolicy registry subkey is set to 1.
  • ASP.NET 2.0 uses the RijndaelManaged implementation of the AES algorithm when it processes view state data. The ReindaelManaged implementation has not been certified by the National Institute of Standards and Technology (NIST) as compliant with the Federal Information Processing Standard (FIPS). Therefore, the AES algorithm is not part of the Windows Platform FIPS validated cryptographic algorithms.
To work around this problem, change the configuration in the application-level Web.config file. Specify that ASP.NET use the Triple Data Encryption Standard (3DES) algorithm to process view state data. To do this, follow these steps:
  1. In a text editor such as Notepad, open the application-level Web.config file.
  2. In the Web.config file, locate the <system.web> section.
  3. Add the following <machineKey> section to in the <system.web> section: <machineKey validationKey="AutoGenerate,IsolateApps" decryptionKey="AutoGenerate,IsolateApps" validation="3DES" decryption="3DES"/>
  4. Save the Web.config file.
  5. Restart the Microsoft Internet Information Services (IIS) service. To do this, run the following command at a command prompt: iisreset
After doing this also if it is not working then set the subkey HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\fipsalgorithmpolicy value to 0



Reference: Muthukumar (http://nadarmuthukumar.blogspot.in), ref
Hope you liked this and let me know your thoughts on post through your comments :)

Nested IF in Microsoft Excel

It is possible to nest multiple IF functions within one Excel formula? Answer is “YES”.
You can nest up to 7 IF functions to create a complex IF THEN ELSE statement.
The syntax for the nesting the IF function is:
IF( condition1, value_if_true1, IF( condition2, value_if_true2, value_if_false2 ))
This would be equivalent to the following IF THEN ELSE statement:
IF condition1 THEN
    value_if_true1
ELSEIF condition2 THEN
    value_if_true2
ELSE
    value_if_false2
END IF
This applies to Excel 2010, Excel 2007, Excel 2003, Excel XP and Excel 2000

Reference: Muthukumar (http://nadarmuthukumar.blogspot.in), Ref1
Hope you liked this and let me know your thoughts on post through your comments :)

Upload file to webserver using c#

  1. Place one Label, FileUpload and Button control to your page.
  2. Name Label control as “lblMessage”, FileUpload control as “fuUpload” and Button control as “btnSubmit”
  3. Create a Method as shown below,
    private bool UploadFile()
    {
        bool _Result = false;
        try
        {
          if (fuUpload.HasFile)
          {
              string strFileName = DateTime.Now.ToString("ddMMyyyy_HHmmss");
              string strFileType = System.IO.Path.GetExtension(fuUpload.FileName).ToString().ToLower();
              strFileName += fuUpload.FileName;
              ViewState["FileName"] = strFileName;
              if (strFileType.ToLower() == ".pdf")
              {
                   fuUpload.SaveAs(Server.MapPath("~/Pdf/" + strFileName));
                   _Result = true;
              }
              else
              {
                   lblMessage.Text = "Only pdf files allowed.";
                   _Result = false;
              }
          }
          else
          {
              _Result = false;
              lblMessage.Text = "Please select valid pdf file";
          }
        }
        catch (Exception ex)
        {
             _Result = false;
             lblMessage.Text = ex.Message;
        }
        return _Result;
    }
    
  4. Now under btnSubmit_click event call the created method as shown below
    if (UploadFile())
    {
         // You can get the uploaded file name from below viewstate
         string FileName = Convert.ToString(ViewState["FileName"]);
    }
    
Reference: Muthukumar (http://nadarmuthukumar.blogspot.in)
Hope you liked this and let me know your thoughts on post through your comments :)

Increment for loop by step n

Normally i++ increments i by 1, in order to increment i by nth count you can use i += n where n is any number.
e.g.
for (int i = 0; i < 11; i += 2)
{
Console.WriteLine(i);
}
Reference: Muthukumar (http://nadarmuthukumar.blogspot.in) Hope you liked this and let me know your thoughts on post through your comments :)

Generate Random Code

Import below into your Namespace
using System.Security.Cryptography;
Declare Below Variables
public const string Alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public const string AlphaNumeric = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
public const string Numeric = "1234567890";
Create a Enum as below
public enum StringType { Alpha, AplhaNumeric, Numeric }
Create a Method as below
public static string GenerateRandomCode(int CodeSize, StringType objStringType)
        {
            string RandomCode = string.Empty;
            try
            {
                char[] chars = new char[62];
                if (objStringType == StringType.AplhaNumeric)
                    chars = AlphaNumeric.ToCharArray();
                else if (objStringType == StringType.Numeric)
                    chars = Numeric.ToCharArray();

                byte[] data = new byte[1];
                RNGCryptoServiceProvider crypto = new RNGCryptoServiceProvider();
                crypto.GetNonZeroBytes(data);
                data = new byte[CodeSize];
                crypto.GetNonZeroBytes(data);
                StringBuilder result = new StringBuilder(CodeSize);
                foreach (byte b in data)
                    result.Append(chars[b % (chars.Length - 1)]);
                RandomCode = result.ToString();
            }
            catch (Exception ex)
            {
                //throw ex;
            }
            return RandomCode;
        }

You can call the method using below code
Response.Write(GenerateRandomCode(4, StringType.Numeric));

Reference: Muthukumar (http://nadarmuthukumar.blogspot.in)
Hope you liked this and let me know your thoughts on post through your comments :)

80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Recently I was having a task to work with Word Automation. I have created word file and everything sucessfully. When I deployed the same to Server it failed and thown me below error,

Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).


After going into lots of research below solution worked for me.

<system.web>
<identity impersonate="true"
userName="Server User Name"
password="Server Password" />
</system.web>


Add Above to your webconfig file.

Reference: Muthukumar (
http://nadarmuthukumar.blogspot.in)
Hope you liked this and let me know your thoughts on post through your comments :)

Twitter Delicious Facebook Digg Stumbleupon Favorites More