Monday, November 28, 2011

Basic Authentication


protected override System.Net.WebRequest GetWebRequest(Uri uri)
        {
            string pass = "pass" + ":" + "****";           
            var key = Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes(pass));
            var basicKey= "Basic " + key;
            var getWebRequest = base.GetWebRequest(uri);          
            getWebRequest.Headers.Add("authorization", basicKey);
            return getWebRequest;
        }

Wednesday, November 2, 2011

The remote server returned an error: (404) Not Found

In web.config file, change endpoint address http to basic

Tuesday, October 11, 2011

InArgument and OutArgument in Workflow(WF 4)


            //Input Argument WF
            IDictionary<string, object> inputs = new Dictionary<string, object>
            {
                {"Person1", new Person{ Name="Tom", Age=26}}
            };
            
            //Output Argument
            IDictionary<string,object> outputs=WorkflowInvoker.Invoke(new Activity1(),inputs);
            Console.WriteLine(outputs["Accepted"].ToString());




Elmah Error Filtering(Ignore Some Exceptions)


Open the Global.asax file then write code;

void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
        {
            if (e.Exception.GetBaseException() is FileNotFoundException || e.Exception.GetBaseException() is HttpException)
                e.Dismiss();
        }

Send Mail on Exception With Extensible Method


class Program
    {
        static void Main(string[] args)
        {
            try
            {
                throw new Exception("Expection");
            }
            catch (Exception ex)
            {
                ex.SendErrorEmail();
            }
        }
    }
    public static class MyExtension
    {
        public static void SendErrorEmail(this Exception ex)
        {
            //Write your send mail code
            //....
            smtpClient.Send(mailMessage);
        }
    }

Could not allocate space for object.


 In SqlServer right click on the database,select Database Properties.Then Go to Files section. Click the Autogrowth, select Unresticted File Growth.

How do you determine if your SQL Server Database is 32 or 64-bit?


select @@version