Thursday, October 20, 2016

Types of exception in c#

A C# exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. Exceptions provide a way to transfer control from one part of a program to another.

C# exception handling is built upon four keywords: try, catch, finally, and throw.

  • try: A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.

  • catch: A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.

  • finally: The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not.

  • throw: A program throws an exception when a problem shows up. This is done using a throw keyword.

Types of Exceptions in C#

Exception Class

Description

System.IO.IOException

Handles I/O errors.

System.IndexOutOfRangeException

Handles errors generated when a method refers to an array index out of range.

System.ArrayTypeMismatchException

Handles errors generated when type is mismatched with the array type.

System.NullReferenceException

Handles errors generated from deferencing a null object.

System.DivideByZeroException

Handles errors generated from dividing a dividend with zero.

System.InvalidCastException

Handles errors generated during typecasting.

System.OutOfMemoryException

Handles errors generated from insufficient free memory.

System.StackOverflowException

Handles errors generated from stack overflow.

Wednesday, September 14, 2016

Disable Popup “Please Fill Out this Field” hover text on browsers

This is message “Please fill out this field” is browser default message which comes from browser when we have required fields in the page.

This his how browsers handles the HTML5 "required" attribute. Since those fields have the attribute "required", the browser adds that message on hover.  I have seen this in Mozilla and Chrome versions.

Simple fix for this issue is use formnovalidate in whatever button that triggers the prompt or simply use novalidate in form tag. Either one is sufficient to disable browser default validation

Example:

<form action="post.ashx" method="post" novalidate>
<input type=submit formnovalidate name=save value="Save">
<input type=submit formnovalidate name=cancel value="Cancel">
</form>

Find out more here using AngularJs

How to extract back up file?

To manually extract files

1. Open the Command Prompt window by clicking the Start button.
   In the search box, type Command Prompt, and then, in the list of results, click Command Prompt.
  
2. Type the following command:
C:\Users\Nagasai\Downloads>copy "Send_file_test.bak" “Send_file_test.mdb”

Hope this helps!!!

Monday, September 12, 2016

405 - HTTP verb used to access this page is not allowed

We get the above error when we use PUT verb when we access RESTFUL web services.

For this to work, The web site had to continue to enable WebDAV, but the web application needed to turn it off in order to support PUT and DELETE in its REST API.

Below are the approaches I followed to solve my problem.

Procedure 1:

  1. In the IIS Manager, select the application that needs to support PUT.  
  2. In the Features View, find WebDAV Authoring Rules.  Double-click it, or select Open Feature from the context menu (right-click).
  3. In the Actions pane, find and click on WebDAV Settings....
  4. In the WebDAV Settings, find Request Filtering Behavior, and under that, find Allow Verb Filtering.  Set Allow Verb Filtering to False. 2016-09-14_1402
  5. In the Actions pane, click Apply.

Procedure 2:

1. Go to IIS Manager.
2. Click on your app.
3. Go to "Handler Mappings".
4. In the feature list, double click on "WebDAV".

2016-09-14_1411
5. Click on "Request Restrictions".
6. In the tab "Verbs" select "All verbs" .

2016-09-14_1412
7. Press OK.

Hope this helps!

Sunday, August 28, 2016

How transform Image using CSS/HTML

I want to turn the image full 180 degrees, this is how we CSS can help turn image upside down.

div {
    -ms-transform: rotate(180deg); /* IE 9 */
    -webkit-transform: rotate(180deg); /* Chrome, Safari, Opera */
    transform: rotate(180deg);
}