Refinance now before rates go up! Get multiple rate quotes at GetMyLender.com.
Showing posts with label Asp.Net. Show all posts
Showing posts with label Asp.Net. Show all posts

C# Reflection Examples

C# Reflection Examples

Reflection Examples [C#]

This example shows how to dynamically load assembly, how to create object instance, how to invoke method or how to get and set property value.

Create instance from assembly that is in your project References

The following examples create instances of DateTime class from the System assembly.

ASP.NET Webdomain Recycles Automatically on Deletion of Sub-directory

While working on a web application, once upon a time I was presented some weird behavior on ASP.NET.

In ASP.Net web application, When you delete a directory the session gets expired automatically. This is one of the frustrating error. It is the default nature if you are deleting a sub-directory within your application, your app domain will restart. This removes all session data.

Following observations will help you to find base of this issue:
- Session times out randomly while working on the application.

How to Maintain Session in ASP.NET application after deletion of subdirectory

In ASP.Net web application, When you delete a directory the session gets expired automatically. This is one of the frustrating error. It is the default nature if you are deleting a subdirectory within your application, your app domain will restart. This removes all session data.

Why the asp.net worker process recycles which kills all the session variables in memory is due to dynamically deleting a folder under the root application folder.
ASP.NET runs a File Monitor (FCN) that observes any change to the structure of the Virtual Directory. In case of any change the application is recycled.

Minify CSS and JS file using Visual Studio 2012

Before going on our main topic we have to discuss about one of the Dot Net feature i.e. Microsoft’s Web Optimization Framework. So, what is Web Optimization Framework and how to use this framework in Asp.net web form application? Microsoft’s (ASP.NET) Web Optimization Framework introduces a way to bundle and optimize CSS and JavaScript files.

If anyone wants to install Microsoft ASP.NET Web Optimization Framework, run the following command in the Package Manager Console of Visual Studio 2012.

C-Sharp Code to Check if Internet Connection is Available or Not

In some of our applications it is necessary to connect to Internet. So before connecting to Internet it is necessary to check, whether your application has Internet access.

May be you are thinking to solve this problem just by ping -ing to google.com or any websites. Yes this will work in most of the cases, and it is also a simple, good and important method. But as an Application developer it is not the best method to do that.

Difference between GET and POST Methods

In this article, we will discuss about difference between GET and POST Methods. So that it will usefull in your apllications.

GET Method ():

1) Data is appended to the URL.
2) Data is not secret.
3) It is a single call system.
4) Maximum data that can be sent is 256.

What is the Difference between Ref and Out in c sharp with Examples

In this post we will learn about ref and out parameters in c# with examples. While looking forward, we have to know about ref and out parameters and how we can use it and where to use ? Both ref and out parameters are used to pass as an arguments to a method. Actually method can return zero or one value, so these parameters are very helpful whenever methods want to return more than one value.

So, what is the main difference between these both parameters?

Both parameters used for same purpose but ref parameter need to initialize it before passing to the method and out parameter you don’t need to initialize before passing to function. Here we will go in more detail by using examples.

How to Increase Performance of Stored Procedures

When we fire SQL for the first time, three things happen:

• The SQL syntax is checked for any errors.
• The best plan is selected to execute the SQL (choice to use clustered index, non-clustered etc.).
• Finally the SQL is executed.

As in one of the article Mr. Shivprasad koirala says that Stored Procedures Do Not increase performance. Performance of inline parameterized SQL is the same as that of Stored Procedures. They had also proved why Stored procedure to be used.

Regular Expression in Dot Net Framework Part I - Character Escapes and Character Classes

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.

Each section in this quick reference lists a particular category of characters, operators, and constructs that you can use to define regular expressions:

Regular Expression in Dot Net Framework Part V - Regular Expression Options and Miscellaneous Constructs

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


Regular Expression Options

You can specify options that control how the regular expression engine interprets a regular expression pattern. Many of these options can be specified either inline (in the regular expression pattern) or as one or more RegexOptions constants.

Regular Expression in Dot Net Framework Part IV - Alternation Constructs and Substitutions

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


Alternation Constructs

Alternation constructs modify a regular expression to enable either/or matching. These constructs include the language elements listed in the following table.

Regular Expression in Dot Net Framework Part II - Anchors Grouping and Constructs

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


Anchors

Anchors, or atomic zero-width assertions, cause a match to succeed or fail depending on the current position in the string, but they do not cause the engine to advance through the string or consume characters. The metacharacters listed in the following table are anchors.

Regular-Expression-in-Dot-Net-Framework-Part-III-Quantifiers-and-Backreference-Constructs

A regular expression is a pattern that the regular expression engine attempts to match in input text. A pattern consists of one or more character literals, operators, or constructs.


Quantifiers

A quantifier specifies how many instances of the previous element (which can be a character, a group, or a character class) must be present in the input string for a match to occur. Quantifiers include the language elements listed in the following table.

What is AutoEventWireup attribute and its use in ASP.NET ?

AutoEventWireup attribute in ASP.NET

AutoEventWireup is an attribute of the @ Page directive. The AutoEventWireup attribute may have a value of true or false. The value is set to false when you create a new ASP.NET Web Application.

This article describes what is AutoEventWireup attribute and its use in ASP.NET. This article also describes some of the options of this attribute by using coding and examples of the ASP.NET Web Forms code that is written in Microsoft Visual C# .NET.

You can specify a default value of the AutoEventWireup attribute in several places:
1) The Machine.config file
2) The Web.config file
3) Individual ASP.NET Web Forms (.aspx files)
4) Web User Controls (.ascx files)

Difference between Int32.Parse(), Convert.ToInt32() and Int32.TryParse() in C#

In this article, we will discuss what are the differences between Int32.Parse(), Convert.ToInt32() and Int32.TryParse() in C# and when and which will be useful in programs.

As you are already known about int in C#. It is used to hold integer value in memory which represents a 32-bit signed integer. While coding many times you come across int, Int16, Int32, Int64. int and Int32 are likely to be same.
All these are stuct type means value type/premetive type.
int => System.Int32 and Represents a 32-bit sigened integer.
Int16 => System.Int16 and Represents a 16-bit sigened integer.
Int32 => System.Int32 and Represents a 32-bit sigened integer.
Int64 => System.Int64 and Represents a 64-bit sigened integer.

Singleton Pattern In C Sharp

What is Singleton Pattern ?

Singleton pattern is one of the simplest design patterns. This pattern ensures that a class has only one instance and provides a global point of access to it.

History of Design Patterns :

Singleton pattern falls under Creational Pattern of Gang of Four (GOF) Design Patterns in .Net.

In 1994, four authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book (Design Patterns : Elements of Reusable Object-Oriented Software) for explaining the concept of Design Pattern in Software development. These four authors are collectively known as Gang of Four (GOF).

The 23 Design patterns are defined by the Gang of Four programmers. These 23 patterns are divided into three groups depending on the nature of the design problem they intend to solve.

Groups are 1) Creational Design Patterns 2) Structural Design Patterns 3) Behavioral Design Patterns.

Out of these three groups, singleton is the Creational Design Patterns.

A potentially dangerous Request.Form value was detected from the client in asp.net

A few days ago, while working on an ASP.NET 4.0 Web project, I got following issue.

“A potentially dangerous Request.Form value was detected from the client…..”

This issue occurred when I tried to enters some non-encoded HTML content as a product details into the rich textbox.

e.g.: “<p>Hello</p>”

After enter the above html data in Rich Textbox and I tried to insert data then I got error message like

How To Add MIME Types In IIS7

Many times we used IIS7 (Internet Information Service) as a server for our web projects also while working with a audio, video, text files etc for web application, sometimes it will happened that our browser showing some errors that comes from server side. And audio/video files may not work (just like video not playing) and server gives error. If that error is understandable by us then its good but what to do if it is not understandable?

First of all I want to tell you, many times it is happened because file format/extension of audio/video file which we want to play on browser is not known to IIS. So video will not play and error will be shown like video/mp4 MIME type is not supported. Now, then what to do so that IIS knows file format ? or how we can see whether file format is configured on server or not? And if file format is not configured then how will you add that type to IIS?

List of MIME Types / Internet Media Types

What is a MIME type?

MIME stands for "Multipurpose Internet Mail Extensions. It's a way of identifying files on the Internet according to their nature and format. For example, using the "Content-type" header value defined in a HTTP response, the browser can open the file with the proper extension/plugin.

What is an Internet Media Type?

"Internet Media Type" is the same as a MIME type. MIME types were originally created for emails sent using the SMTP protocol. Nowadays, this standard is used in a lot of other protocols, hence the new naming convention "Internet Media Type".