Monday, June 30, 2014

Asp.net Security: EnableViewStateMac Property

For Asp.net web application security, you should never set EnableViewStateMac to false. Because A ViewStateMac is an encrypted version of the hidden variable that a page's view state is persisted to when the page is sent to the browser. When this property is set to true, the encrypted view state is checked to verify that it has not been tampered with on the client.

By default value for EnableViewStateMac is true. MAC stands for Message Authentication Codes. It gets or sets a value indicating whether ASP.NET should check message authentication codes (MAC) in the page's view state when the page is posted back from the client.

Do not set this property in code. Set the EnableViewStateMac attribute using the @ Page directive in the .aspx file. When the page is requested, the dynamically generated class sets the property.

<%@ Page language="C#" EnableViewStateMac="true" %>

Note: This attribute should never be set to false in a production Web site, even if the application or page does not use view state. The view state MAC helps ensure the security of other ASP.NET functions in addition to view state.

In Asp.net 4.5.2, the runtime enforces EnableViewStateMac=true. Even if you set it to false, the runtime will ignores this value and proceeds with the value set to true.

Friday, June 27, 2014

Very Simple WCF Example with IIS in Asp.net

Today I would like to show you very simple example on WCF hosted on IIS. I am using Visual studio 2012. So let's start creating a very very simple WCF example.

Steps are following for "SERVICE".

Step 1. Open visual studio and click on file menu -> New -> Project

Step 2. Select "Asp.net Empty Web Application" with .Net Framework 4.5 and give Name "SimpleWCF" and checked checkbox on "Create directory for solution." and then click OK.

Step 3. Now, Right click on project and Add New Item "AJAX-enabled WCF Service" and give name "Hello.svc" and click ADD.

Step 4. By default, it will add some code, so first delete all the existing code and make that file as following.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;

namespace SimpleWCF
{
     
    public class Hello :IHello 
    {

        public string getResponse(string name)
        {
            return "Hello " + name;
        }
    }

    [ServiceContract]
    public interface IHello {

        [OperationContract]
        string getResponse(string name);
    }
}

Step 5. Open web.config file and make changes like following.
<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>

    <system.serviceModel>
        <behaviors>
   <serviceBehaviors>
    <behavior>
     <serviceMetadata httpGetEnabled="true"/>
    </behavior>
   </serviceBehaviors>
        </behaviors>
        
    </system.serviceModel>
</configuration>


That's it! Service is ready.

Now, Steps are following for "CLIENT".

Step 1. Right click on the same solution -> Add -> New Project

Step 2. Select "Asp.net empty web application" with .net framework 4.5 and give name "SimpleWCFClient" and click OK.

Step 3. Now, right click on this project and "Add Service Reference".

Step 4. In this dialog box, add Address, in my case, i have "http://localhost:54304/Hello.svc" and click GO.

Step 5. You can see your Service and give name "HelloClientService" and Click OK.

Step 6. It will automatically add all the necessary code in web.config like following.
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>

    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IHello" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:54304/Hello.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IHello" contract="HelloClientService.IHello"
                name="BasicHttpBinding_IHello" />
        </client>
    </system.serviceModel>
</configuration>

Step 7. Now right click on project and add New Item "Web Form" and name it "Default.aspx"

Step 8. In code behind of this default.aspx page, write following code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SimpleWCFClient
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HelloClientService.HelloClient hc = new HelloClientService.HelloClient();
            string result = hc.getResponse("John Miller");
            hc.Close();
        }
    }
}

Result will be:
Hello John Miller
You can see, it will return response with "Hello" in prefix. This is very simple example and project structure will look like following:

Thursday, June 26, 2014

How to redirect parent window on particular page when we close the modal popup window? using JQuery or Javascript (NOT on reload or post back)

I was looking for JQuery solution which will fire only when I close a modal popup window. I found some JQuery examples but none of them gave me correct JQuery solution. What I was looking is that whenever I close the modal popup Window, it prompts with message before closing and redirect to particular page. So I got the following JQuery solution, But the issue in this solution is that it will fire on both event "close" and "reload or post back". This is wrong. I want a JQuery solution which should work only on closing a modal popup window, not on reload or post back.

     $(window).unload(function() {
           //redirection code here
           alert('your message');   
     });

So after some research, I made it and solved the issue with following. I hope this will help you as well.
     $(window).unload(function(event) {
        if (event.target.readyState=='complete') {

            alert('Closing Window and redirecting...');
            var opener = window.dialogArguments;
            opener.parent.location = '../YourRedirected.aspx?id=<%=Record_ID %>';
            top.window.close();

        }
        else {
            alert('Reloading Window');
        }   
     });

Which project management style is right for you?

Sometimes, the secret to a successful project is selecting the right project management style. Establishing an effective framework is crucial for any project to run smoothly. But when you have "WATERFALL" and "AGILE" planning methods to choose from, how do you know which is the best for your project and team?

Here's a list of the pros and cons for each method to help you decide.

WATERFALL


Water fall requires detailed planning at the beginning of a project. All the steps are laid out, dependencies mapped, and you move to the next stage only after completing the previous one.

Pros.

  • Best for projects that deal with physical objects - from a construction project to a hardware installation project.
  • Best for projects with defined tasks and phases that must be completed in a specific sequence (e.g. build the first floor of a building before the second floor).
  • Project plans are repeatable for identical or similar projects in the future.

Cons.

  • Requires substantial scope and schedule planning before work begins.
  • Scope changes can be slow and require formal change control processes.
  • Less effective for software, design and other non-physical or service-based projects.


AGILE


This is a fast and flexible approach to project management based on principles of collaboration, adaptability and continuous improvement. Unlike the orderly stages of a waterfall approach, agile project management is typically set up in quick, iterative project release cycles.

Pros.

  • Best for projects that deal with services-oriented and non-physical deliverables like code, copywriting and design projects.
  • Allows for quick course correction based on stakeholder feedback.
  • Empowers project teams to work creatively and efficiently.
  • Includes engagement and collaboration from all team members.

Cons.

  • Not suited for projects with strictly defined requirements and scope.
  • Uncertainty around scope and schedules can make stakeholders and executives nervous (at first).
  • Requires vigilant backlog and documentation maintenance, and tech debt management.


Wednesday, June 25, 2014

How to do INNER JOIN, LEFT JOIN and RIGHT JOIN in LINQ as well as in SQL? Part 1

Today I will show you how to write LINQ Query as well as SQL Query. Both LINQ and SQL examples will clear your idea about INNER JOIN, LEFT JOIN and RIGHT JOIN. And also it will show you different results based on different JOINs.

Let’s create platform for it. Suppose we have following tables with data.
SELECT * FROM CUSTOMER


SELECT * FROM CITY


Now we will write SQL Queries for INNER JOIN, LEFT JOIN and RIGHT JOIN.
--Inner Join
SELECT cust.Name 
FROM CUSTOMER cust
 INNER JOIN CITY ct 
  ON ct.id = cust.city_id
  
--Left Join
SELECT cust.Name
FROM CUSTOMER cust
 LEFT JOIN CITY ct 
  ON ct.id = cust.city_id
 
--Right Join
SELECT ct.name AS City  
FROM CUSTOMER cust
 RIGHT JOIN CITY ct 
  ON ct.id = cust.city_id

After SQL, we will write LINQ Queries in C# for INNER JOIN, LEFT JOIN and RIGHT JOIN.
            
using (MyTestEntities db = new MyTestEntities())
{

 //Inner Join
 var results = (from Customer cust in db.Customers
                join City ct in db.Cities
                on cust.City_Id equals ct.Id
                select cust.Name).ToList();


 //Left Join
 results = (from Customer cust in db.Customers
            join City ct in db.Cities 
            on cust.City_Id equals ct.Id into Joined
            from lj in Joined.DefaultIfEmpty()
            select cust.Name).ToList();


 //Right Join (Just swap it)
 results = (from City ct in db.Cities
            join Customer cust in db.Customers 
            on ct.Id equals cust.City_Id into Joined
            from rj in Joined.DefaultIfEmpty()
            select ct.Name).ToList();

}
Now it's time to see results:

INNER JOIN Result for both queries will be like this



LEFT JOIN Result for both queries will be like this



RIGHT JOIN Result for both queries will be like this




Now you can compare SQL, LINQ and Result to get clear idea about it.

Tuesday, June 24, 2014

How to Insert Values into an Identity Column in SQL Server?

To insert values into an identity column, you have to first set identity_insert ON and after inserting or updating, you have to set it OFF like following:
SET IDENTITY_INSERT [dbo].[YourTableName] ON 
GO
INSERT INTO [dbo].[YourTableName]
           ([ID] 
           ,[Code]
           ,[Description]
           ,[Required_by_System] )
     VALUES
           (9
           ,900
           ,'Record Updated'
           ,'Y' )
GO
SET IDENTITY_INSERT [dbo].[YourTableName] OFF
GO

Monday, June 23, 2014

Simple example for Asp.net MVC 4 and Entity Framework for Add/Edit/Delete/View/List Customers

Today we will create very simple Asp.net MVC 4 application with entity framework which will give you basic idea about MVC and entity framework. I am going to use “database first” workflow for entity framework.

Let’s start with following steps:

Step 1: Create a new project with .net 4.5 and choose Asp.net MVC 4 Web application and give name “MvcDemo” and click ok.

Step 2: Now choose “Empty” in template selection. View engine will be “Razor” by default and click Ok. This will create project with basic files and folders.

Step 3: Please create database and create “customer” table with following script.

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Customer](
 [Id] [int] IDENTITY(1,1) NOT NULL,
 [Name] [nvarchar](50) NULL,
 [City] [nvarchar](50) NULL,
 [State] [nvarchar](50) NULL,
 CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED 
(
 [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, 
IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, 
ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

Step 4: We will create entity model in our project, for this, right click on “Models” folder and add new item as following and give name “MvcModel”.



Step 5: Select “Generate from database” and click next :



Step 6: Choose “connection string”, click “new connection” and give your database connection and name it “MvcDataEntities” and click Next.



Step 7: Choose “Customer” table and click on finish.



Step 8: This will create model :



Step 9: We have model, now we will create controller which will automatically create views for us.

Step 10: Right click on “Controllers” folder and add “HomeController” with Template “MVC controller with read/write actions and views, using Entity Framework." and click Add.



Step 11: This will create “HomeController” and also associated Views like create.cshtml, delete.cshtml, edit.cshtml etc… :



Step 12: Make it start up project and run. Initial screen will look like following:



Step 13: Click on “Create New” and it will give you following error:



Step 14: To solve this, you have to run nuget package with following command :
Install-Package Microsoft.AspNet.Web.Optimization


Step 15: once you run this nuget package, you have to add namespace in web.config like following.
<add namespace="System.Web.Optimization"/> 

Step 16: Now run your project and you can successfully add, edit, delete and view list of cutomers.

the name 'Scripts' does not exists in the current context in Asp.net MVC 4

You will get this error message when you want to build asp.net MVC 4 application with blank solution. To solve this issue, you have to install the following nuget package in your project:
Install-Package Microsoft.AspNet.Web.Optimization
And also in web.config, add following:
<add namespace="System.Web.Optimization"/> 
It will solve your issue.

Friday, June 20, 2014

Cache Aggressively – Performance Tips for ASP.NET Applications

Tip 3. Cache Aggressively

When designing Asp.net application, make sure you put all static pages in cache. You can cache data as well as pages/user controls. Asp.net 4.0 also providing extensible output cache through which you can put your cache on local or remote disks, cloud storage and distributed cache engines.

Caching makes significant performance improvement in your application.

You can cache data using application cache which provides a programmatic way to store data in memory using key/value pairs.

You can cache page using page output cache. Output caching enables you to store rendered HTML. You can cache a whole web page or just the output of Asp.net control.

An application can often increase performance by storing data in memory that is accessed frequently and that requires significant processing time to create. For example, if your application processes large amounts of data using complex logic and then returns the data as a report accessed frequently by users, it is efficient to avoid re-creating the report every time that a user requests it. Similarly, if your application includes a page that processes complex data but that is updated only infrequently, it is inefficient for the server to re-create that page on every request.

To help you increase application performance in these situations, ASP.NET provides caching using two basic caching mechanisms. The first is application caching, which allows you to cache data you generate, such as a DataSet object or a custom report business object. The second is page output caching, which saves the output of page processing and reuses the output instead of re-processing the page when a user requests the page again.

Thursday, June 19, 2014

What is SSAS? (SQL Server Analysis Services)

SQL Server Analysis Services (SSAS) delivers online analytical processing (OLAP) and data mining functionality for business intelligence applications. Analysis Services supports OLAP by letting you design, create, and manage multidimensional structures that contain data aggregated from other data sources, such as relational databases. For data mining applications, Analysis Services lets you design, create, and visualize data mining models that are constructed from other data sources by using a wide variety of industry-standard data mining algorithms.

What is SSIS? (SQL Server Integration Services)

Microsoft Integration Services is a platform for building enterprise-level data integration and data transformations solutions. You use Integration Services to solve complex business problems by copying or downloading files, sending e-mail messages in response to events, updating data warehouses, cleaning and mining data, and managing SQL Server objects and data. The packages can work alone or in concert with other packages to address complex business needs. Integration Services can extract and transform data from a wide variety of sources such as XML data files, flat files, and relational data sources, and then load the data into one or more destinations.

Integration Services includes a rich set of built-in tasks and transformations; tools for constructing packages; and the Integration Services service for running and managing packages. You can use the graphical Integration Services tools to create solutions without writing a single line of code; or you can program the extensive Integration Services object model to create packages programmatically and code custom tasks and other package objects.

Use Session State Only If You Need To - Performance Tips in Asp.net

Tip 2. Use Session State Only If You Need To

One extremely powerful feature of ASP.NET is its ability to store session state for users, such as a shopping cart on an e-commerce site or a browser history. Since this is on by default, you pay the cost in memory even if you don't use it. If you're not using Session State, turn it off and save yourself the overhead by adding <@% EnabledSessionState = false %> to your asp.

For pages that only read session state, you can choose EnabledSessionState=readonly. This carries less overhead than full read/write session state, and is useful when you need only part of the functionality and don't want to pay for the write capabilities.

Throw Fewer Exceptions - Performance Tips for Asp.net

Performance is must for any successful project. I will try to give you some performance tips in “Performance Tips” category in my blog.

Tip 1. Throw Fewer Exceptions.

Throwing exceptions can be very expensive to your project. So make sure that you don’t throw a lot of them. I recommend that test your project thoroughly and try to handle all the error instead of throwing them and catching them into database. Why? See below example and its result. Note that this has nothing to do with try/catch blocks: you only incur the cost when the actual exception is thrown. You can use as many try/catch blocks as you want.
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            int j = 0;
            for (int i = 0; i < 1000; i++)
            {
                try
                {
                    j = i / j; //Attempted to divide by zero.
                    //This code will throw exception

                }
                catch { }
            }

            sw.Stop();

            Response.Write("With exception : " +
                sw.ElapsedMilliseconds.ToString() + " Milliseconds.");

            sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            j = 0;
            for (int i = 0; i < 1000; i++)
            {
                try
                {
                    if (j > 0) //Handle like this will improve performance.
                    {
                        j = i / j;  
                    }
                }
                catch { }
            }

            sw.Stop();

            Response.Write("WITHOUT exception : " +
                sw.ElapsedMilliseconds.ToString() + " Milliseconds.");
Result will be:
With exception : 15772 Milliseconds.
WITHOUT exception : 0 Milliseconds. 


In above code, you can see clearly that if we handle error or try to eliminate it, it will improve performance tremendously.

Wednesday, June 18, 2014

How to create simple chat application using SignalR 2.0 in Asp.net?

Today I will show you how to create simple chat application using SignalR. The tutorial demonstrates the following SignalR development tasks:

• Adding the SignalR library to an ASP.NET web application.

• Creating a hub class to push content to clients.

• Creating an OWIN startup class to configure the application.

• Using the SignalR jQuery library in a web page to send messages and display updates from the hub.

The following screen shot shows the chat application running in a browser.



Steps are following:

Step 1: Create a new project in .NET 4.5 “Asp.net Empty Web Application” like following.



Step 2: As I am using Visual Studio 2012, I have to manually run the following command to install “Microsoft.AspNet.SignalR” which will add necessary script files and assembly references to support SignalR.

install-package Microsoft.AspNet.SignalR


Go to “Tools” -> Library Package Manager -> Click on Package Manager Console

Choose default project to Your SimpleChat project and write “install-package Microsoft.AspNet.SignalR” in the console and press “Enter” to install. Console looks like following.



Now we need "json2.js". To install this file in our project follow THIS ARTICLE. This is necessary to work smoothly with SignalR application.

Step 3: Create “Users” folder in your project and Create User.cs file in it like this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SimpleChat.Users
{
    public class User
    {
        public string Name { get; set; }
        public string Id { get; set; }
    }
}

Step 4. Create “UserRepository.cs” file in “Users” foler like this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SimpleChat.Users
{
    public static class UserRepository
    {
        static List<User> lstUser = new List<User>();

        public static void add(User u)
        {
            lstUser.Add(u);
        }

        public static User getById(string id)
        {
            return lstUser.Where(usr => usr.Id == id).FirstOrDefault();

        }
        public static User getByName(string name)
        {
            return lstUser.Where(usr => usr.Name == name).FirstOrDefault();

        }
        public static List<User> getAll()
        {
            return lstUser;
        }
        public static void remove(User u)
        {
            lstUser.Remove(u);
        }
    }
}

Step 5. Create “ChatHub.cs” file in your project like this.
using System;
using System.Web;
using Microsoft.AspNet.SignalR;
namespace SimpleChat
{
    public class ChatHub : Hub
    {
        public void Send(string ToName, string message, string FromName)
        {
            //Check ToName, If ToName is specified, send message to that specified Name
            //If ToName is not specified, Send to All Users
            if (ToName != null)
            {
                //Get the ConnectionId of ToName
                string id = Users.UserRepository.getByName(ToName).Id;
                
                //Send message to specified User
                Clients.Client(id).broadcastMessage(FromName, message);

                //Check, if it is not self
                if (id != Context.ConnectionId.ToString())
                {
                    Clients.Client(Context.ConnectionId.ToString()).broadcastMessage("Me", message);
                }
            }
            else
            {
                //Send to all because no user selected.
                Clients.All.broadcastMessage(FromName, message);
            } 
        }

        //Add User in listview
        public void AddUser(string userName)
        {
            Users.User u = new Users.User();
            u.Id = Context.ConnectionId.ToString();
            u.Name = userName;
            Users.UserRepository.add(u);

            Clients.All.updateuserslist(userName);
        }

        //If user leaves the browser, remove from listview or from online users list.
        public override System.Threading.Tasks.Task OnDisconnected()
        {
            Users.User u = Users.UserRepository.getById(Context.ConnectionId.ToString());
            if (u != null)
            {
                RemoveUser(u.Name);
                Users.UserRepository.remove(u);

            }

            return base.OnDisconnected();
        }
        public void RemoveUser(string name)
        {
            Clients.All.updateuserslist_remove(name);
        }

    }
}
Step 6. Create “Startup.cs” file in your project like this.
using Microsoft.Owin;
using Owin;
[assembly: OwinStartup(typeof(SimpleChat.Startup))]
namespace SimpleChat
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // Any connection or hub wire up and configuration should go here
            app.MapSignalR();
        }
    }
}

Step 7. Create “index.aspx” file in your project like this.
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>SignalR Simple Chat</title>
    <style type="text/css">
        .container {
            border: 0px solid #808080;
        }
    </style>

</head>
<body>

    <!--Script references. -->
    <!--Reference the jQuery library. -->
    <script src="Scripts/jquery-1.6.4.js"></script>
    <script src="Scripts/json2.js"></script>
    <!--Reference the SignalR library. -->
    <script src="Scripts/jquery.signalR-2.1.0.js"></script>
    <!--Reference the autogenerated SignalR hub script. -->
    <script src="signalr/hubs"></script>
    <!--Add script to update the page and send messages.-->
    <script type="text/javascript">
        $(function () {
            // Declare a proxy to reference the hub. 
            var chat = $.connection.chatHub;
            // Create a function that the hub can call to broadcast messages.
            chat.client.broadcastMessage = function (name, message) {
                // Html encode display name and message. 
                var encodedName = $('<div />').text(name).html();
                var encodedMsg = $('<div />').text(message).html();
                // Add the message to the page. 
                $('#discussion').append('<li><strong>' + encodedName
                    + '</strong>:  ' + encodedMsg + '</li>');
            };

            //Update listview to add user
            chat.client.updateuserslist = function (name) {
                $('#ddlUsers').append(
                    $('<option></option>').val(name).html(name)
                );

            };

            //Update listview to remove user
            chat.client.updateuserslist_remove = function (name) {
                $('#ddlUsers option[value=' + name + ']').remove();

            };
             
            // Set initial focus to message input box.  
            $('#message').focus();
            // Start the connection.
            $.connection.hub.start().done(function () {
                $('#sendmessage').click(function () {
                    // Call the Send method on the hub. 
                    chat.server.send($('#ddlUsers').val(), $('#message').val(), $('#displayname').val());
                    // Clear text box and reset focus for next comment. 
                    $('#message').val('').focus();
                });
                $('#btnEnter').click(function () {
                    // Call the AddUser method on the hub. 
                    chat.server.addUser($('#displayname').val());
                    $('#btnEnter').hide();
                    $('#displayname').hide();
                    $('#FromName').text($('#displayname').val());
                });
            });
        });
    </script>
    <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="displayname" runat="server"></asp:TextBox>

            <input type="button" id="btnEnter" value="Enter Your Name" />
            <br />
            <br />
             
            <table>
                <tr>
                    <td style="vertical-align: top;">Online Users:<br />
                        <asp:ListBox ID="ddlUsers" runat="server"></asp:ListBox>
                    </td>
                    <td style="border:solid 1px black;">
                        <div class="container" style="height: 330px; width: 300px;">
                            <ul id="discussion" style="overflow: auto; height: 280px; width: 250px;">
                            </ul>
                            <span id="FromName"></span>
                            <input type="text" id="message" />
                            <input type="button" id="sendmessage" value="Send" />

                        </div>
                    </td>
                </tr>
            </table>




        </div>
    </form>
</body>
</html>

Step 8. In code behind of “index.aspx” file, which is “index.aspx.cs” file like this.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SimpleChat
{
    public partial class index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                ddlUsers.DataSource = Users.UserRepository.getAll();
                ddlUsers.DataTextField = "Name";
                ddlUsers.DataValueField = "Name";
                ddlUsers.DataBind();


            }



        }


    }
}


That's it! you are ready to run it, BUT before you run your application, make sure that your referencing script files in index.aspx are matching with the project script files. sometimes .js files are updating their version frequently.

In our case, we are referencing following script files:
    <!--Script references. -->
    <!--Reference the jQuery library. -->
    <script src="Scripts/jquery-1.6.4.js"></script>
    <script src="Scripts/json2.js"></script>
    
    <!--Reference the SignalR library. -->
    <script src="Scripts/jquery.signalR-2.1.0.js"></script>
    <!--Reference the autogenerated SignalR hub script. -->
    <script src="signalr/hubs"></script>

And we have following script files in our project structure.


How it works:


1. Run the application.

2. It will ask you for your "Name".

3. Open another browser and paste the same URL. and again give some name.

4. You can see that all the names will be added in "Online Users" list.

5. Once some user will close the browser, User will be removed from the list automatically.

6. Now you can send message to anybody or to all.

7. To send message to all, don't select any user. and To send messsage to particular User, select it from Online Users list and start chating...like following

Tuesday, June 17, 2014

What is SSRS? (SQL Server Reporting Services)

SQL Server Reporting Services provides a full range of ready-to-use tools and services to help you create, deploy, and manage reports for your organization. Reporting Services includes programming features that enable you to extend and customize your reporting functionality.

Reporting Services is a server-based reporting platform that provides comprehensive reporting functionality for a variety of data sources. Reporting Services includes a complete set of tools for you to create, manage, and deliver reports, and APIs that enable developers to integrate or extend data and report processing in custom applications. Reporting Services tools work within the Microsoft Visual Studio environment and are fully integrated with SQL Server tools and components.

With Reporting Services, you can create interactive, tabular, graphical, or free-form reports from relational, multidimensional, or XML-based data sources. Reports can include rich data visualization, including charts, maps, and sparklines. You can publish reports, schedule report processing, or access reports on-demand. You can select from a variety of viewing formats, export reports to other applications such as Microsoft Excel, and subscribe to published reports. The reports that you create can be viewed over a Web-based connection or as part of a Microsoft Windows application or SharePoint site. You can also create data alerts on reports published to a SharePoint site and receive email messages when report data changes.

Monday, June 16, 2014

SignalR doesn’t work in IE – Internet Explorer (SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support)

Today I was working on SignalR Application and I got this error (SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support, e.g. less than IE 8.)

The very simple solution to fix this issue is “Just download JSON2 from Manage NuGet Packages and Install it”.

Steps are:
1. Right click on your project and click on “Manage NuGet Packages”

2. Now, in NuGet window, search “Json2” like following: (Note: you can click on Online, which is on left of NuGet window, to get it from online)



3. Once you have it, just click on “Install” button to install it in your project.

4. Once installation is complete, it will be like following in your project. (make sure that json2.js file will be before SignalR.js)



Now run your app and it works fine.

Friday, June 13, 2014

What is SignalR in Asp.net?

ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available. SignalR supports Web Sockets, and falls back to other compatible techniques for older browsers. SignalR includes APIs for connection management (for instance, connect and disconnect events), grouping connections, and authorization.

Click here to Start learning SignalR application

Thursday, June 12, 2014

Simple Example of Web API in Asp.net

I am creating a very simple example which displays list of customer.

Steps:

1. Create Asp.net Empty Web Application.

2. Create Customer class like this

Public Class Customer

    Public Property Name As String
    Public Property City As String

End Class
3. Adding a Controller.


In Web API, a controller is an object that handles HTTP requests.

Create CustomersController class (Add "Web API Controller Class" and remvoe extra stuff) like this.
Imports System.Net
Imports System.Web.Http
 
Public Class CustomersController
    Inherits ApiController
     
    ' GET api/<controller> '
    Public Function GetAllCustomers() As IEnumerable(Of Customer)
        'Creating test data '
        Dim customers As New List(Of Customer)
        Dim objCustomer As New Customer
        objCustomer.Name = "Miller"
        objCustomer.City = "Camp Hill"
        customers.Add(objCustomer)
        objCustomer = New Customer
        objCustomer.Name = "John"
        objCustomer.City = "Harrisburg"
        customers.Add(objCustomer)
        objCustomer = New Customer
        objCustomer.Name = "Wayne"
        objCustomer.City = "Enola"
        customers.Add(objCustomer)
        objCustomer = New Customer
        objCustomer.Name = "Julie"
        objCustomer.City = "Enola"
        customers.Add(objCustomer)

        Return customers
    End Function
     
End Class
4. Calling the Web API with Javascript and jQuery

In this section, we'll add an HTML page that uses AJAX to call the web API. We'll use jQuery to make the AJAX calls and also to update the page with the results.

Create HTML page (index.html) like this
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <div>
        <h2>All Customers</h2>
        <ul id="customers" ></ul>
    </div>
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script>
        var uri = 'api/customers';

        $(document).ready(function () {
            // Send an AJAX request
            $.getJSON(uri)
                .done(function (data) {
                    // On success, 'data' contains a list of products.
                    $.each(data, function (key, item) {
                    // Add a list item for the product.
                    $('<li>', { text: formatItem(item) }).appendTo($('#customers'));
                    });
                });
        });

        function formatItem(item) {
            return item.Name + ': ' + item.City;
        }
         
    </script>

</body>
</html>
5. Create Global.asax page like this
Imports System.Web.SessionState
Imports System.Web.Http

Public Class Global_asax
    Inherits System.Web.HttpApplication

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
 
        Dim route As New Routing.HttpRoute("api/{controller}")

        GlobalConfiguration.Configuration.Routes.Add("DefaultApi", route)
         
    End Sub
     

End Class
That's it! When you run your web application. Result will be:

All Customers

  • Miller: Camp Hill
  • John: Harrisburg
  • Wayne: Enola
  • Julie: Enola

Project Structure:

Wednesday, June 11, 2014

What is Web API in Asp.net?

ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.

Click here to see simple example of Web API in Asp.net

What is Windows Communication Foundation (WCF)?

Windows Communication Foundation (WCF) is Microsoft’s unified programming model for building service-oriented applications. It enables developers to build secure, reliable, transacted solutions that integrate across platforms and interoperate with existing investments.

What is LINQ (Language-Integrated Query)?

Language-Integrated Query (LINQ) is a set of features introduced in Visual Studio 2008 that extends powerful query capabilities to the language syntax of C# and Visual Basic. LINQ introduces standard, easily-learned patterns for querying and updating data, and the technology can be extended to support potentially any kind of data store. Visual Studio includes LINQ provider assemblies that enable the use of LINQ with .NET Framework collections, SQL Server databases, ADO.NET Datasets, and XML documents.

Simple example on LINQ:

All LINQ query operations consist of three distinct actions:

1.Obtain the data source.
2.Create the query.
3.Execute the query.

    Public Class Customer
        Public Property Name As String
        Public Property City As String
    End Class
        'The Three Parts of a LINQ Query '

        '1. Data source '
        Dim customers As New List(Of Customer)

        Dim objCustomer As New Customer
        objCustomer.Name = "Miller"
        objCustomer.City = "Camp Hill"
        customers.Add(objCustomer)

        objCustomer = New Customer
        objCustomer.Name = "John"
        objCustomer.City = "Harrisburg"
        customers.Add(objCustomer)

        objCustomer = New Customer
        objCustomer.Name = "Wayne"
        objCustomer.City = "Enola"
        customers.Add(objCustomer)

        objCustomer = New Customer
        objCustomer.Name = "Julie"
        objCustomer.City = "Enola"
        customers.Add(objCustomer)

        '2. Query creation '
        Dim enolaCustomers = From oCustomer As Customer In customers _
                               Where oCustomer.City = "Enola" _
                               Select oCustomer


        '3. Query Execution '
        For Each oCustomer As Customer In enolaCustomers
            Response.Write(oCustomer.Name + "<br/>")
        Next
        'Result will be :'
        Wayne
        Julie

What is Asp.net MVC?

MVC stands for model-view-controller. MVC is a pattern for developing applications that are well architected, testable and easy to maintain. MVC-based applications contain:

  • Models: Classes that represent the data of the application and that use validation logic to enforce business rules for that data.
  • Views: Template files that your application uses to dynamically generate HTML responses.
  • Controllers: Classes that handle incoming browser requests, retrieve model data, and then specify view templates that return a response to the browser.

Entity Framework Development Workflows

Entity Framework supports four basic development workflows. You can choose which one is appropriate for you based on following questions.

1. Do you have Existing Database? or
2. Are you going to create New Database?

New Database:

There are two approaches for New Database:

1. Model First
  • Create model in designer
  • Database created from model
  • Classes auto-generated from model
2. Code First
  • Define classes & mapping in code
  • Database created from defined classes
  • Use Migrations to evolve database

Existing Database:

There are two approaches for Existing Database:

1. Database First
  • Reverse engineer model in designer
  • Classes auto-generated from model
2. Code First
  • Define classes & mapping in code
  • Reverse engineer tools available



What is Entity Framework?

Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.

Entity Framework allows you to create a model by writing code or using boxes and lines in the EF Designer. Both of these approaches can be used to target an existing database or create a new database.

Entity Framework: Four Development Workflows

Tuesday, June 10, 2014

How to keep jQuery UI Accordion collapsed by default?

You can do that by setting attribute -> "active: false".

    <script>
        $(function () {
            $("#accordion").accordion({
                collapsible: true,
                active: false 
            });
        });        
    </script>

How to increase Height of accordion 100% in JQuery?

100% means height should be expanded based on height of the content. You can do that by following way.

    <script>
        $(function () {
            $("#accordion").accordion({
                collapsible: true,
                heightStyle: "content"

            });
        });        
    </script>

Monday, June 9, 2014

How to create ErrorHandling Module Using IHttpModule?

I am going to explain IHttpModule using an example here. Imagine that you don’t want to write error handling code in each and every page/class instead you want to create separate “Error Handling” module in your project without touching “Global.asax” file. You can do so by implementing “IHttpModule” interface. Following example shows you very simple code about handling error globally. I am attaching some html in beginning and End of the request. And also in between I am showing the error message occurred anywhere in the project. So here is the sample code.

Public Class ErrorHandlingModule
    Implements IHttpModule
     
    Public Sub Dispose() Implements IHttpModule.Dispose

    End Sub

    Private _ErrorMessage As String
    Public Property ErrorMessage() As String
        Get
            Return _ErrorMessage
        End Get
        Set(ByVal value As String)
            _ErrorMessage = value
        End Set
    End Property


    Public Sub Init(context As HttpApplication) Implements IHttpModule.Init

        'Adding handler for Error '
        AddHandler context.Error, _
            AddressOf Me.Application_Error

        'Adding Begin Request Handler '
        AddHandler context.BeginRequest, _
            AddressOf Me.Application_BeginRequest

        'Adding End Request Handler '
        AddHandler context.EndRequest, _
            AddressOf Me.Application_EndRequest


    End Sub

    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        Dim application As HttpApplication = DirectCast(sender,  _
            HttpApplication)
        Dim context As HttpContext = application.Context

        context.Response.Write("<h3><font color=red>" & _
                "ErrorHandlingModule: Beginning of Request" & _
                "</font></h3><hr/><br/><br/>")

    End Sub

    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        'Handling Error: This is just an example '
        'In real time, you have to log your error in database ' 
        'as well as send email to admin '
        Dim LastException As Exception = HttpContext.Current.Server.GetLastError
        If LastException IsNot Nothing Then
            If LastException.InnerException IsNot Nothing Then

                ErrorMessage = LastException.InnerException.Message

            End If
        End If

        'Clear Error after handling it '
        HttpContext.Current.Server.ClearError()

    End Sub
     
    Sub Application_EndRequest(ByVal sender As Object, ByVal e As EventArgs)
        Dim application As HttpApplication = DirectCast(sender,  _
            HttpApplication)
        Dim context As HttpContext = application.Context



        context.Response.Write(ErrorMessage + "<br/><br/><hr/><h3/><font color=red>" & _
                "ErrorHandlingModule: End of Request</font></h3>")

    End Sub

End Class


Steps:
1. Create a class “ErrorHandlingModule” in “App_Code” folder of your project
2. Implement “IHttpModule” in this class. When you press enter button at the end of “IHttpModule”, It will implement two methods “Dispose() and Init()”.
3. In Init(), I have added three handlers “Error, BeginRequest, EndRequest”.
4. To catch all requests and error, you have to subscribe those in “Init” and create methods in this class.
5. I have created three methods “Application_BeginRequest”, ”Application_Error”, ”Application_EndRequest”.
6. In “Application_Error” Method, just for example, I have assigned error message to “ErrorMessage” property. I have created this property just for that.
7. Now, just to see how it works, I have created one .aspx page and its Page_Load event, I have thrown exception as follows:

Public Class Home
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Throw New Exception("This is test ERROR")

    End Sub

End Class


When you run this page, error will be caught by our ErrorHandlingModule and you can see the result as below. You can log any error in the database as well as you can send an email to admin.

Friday, June 6, 2014

How to increase maximum request length in web.config?

The default upload file size if 4MB. To increase it, please use this below section in your web.config

This code will allow file size upto 20MB.
<configuration>
    <system.web>
        <httpRuntime maxRequestLength="20480" />
    </system.web>
</configuration>


Thursday, June 5, 2014

When and Why we need Interfaces in our Project? VB.Net

Today I will show you when and why we need to implement Interfaces. This is not something that you have to have in your project. There are some scenarios where you have to use Interfaces. I will give you two very simple but effective examples, which will give you a clear idea, when to use Interfaces in your project.

Before I give you basic scenarios, let me prepare the first platform. Here are 5 child classes and one parent class.

Public MustInherit Class Animal
    Public Property Legs As Integer
End Class
Public Class Cow
    Inherits Animal

    Public Property AverageMilkQuantity As Integer
 
End Class
Public Class Buffalo
    Inherits Animal

    Public Property AverageMilkQuantity As Integer

End Class
Public Class Camel
    Inherits Animal

    Public Property AverageMilkQuantity As Integer

End Class
Public Class Lion
    Inherits Animal

    Public Property MeatEatingQuantity As Integer

End Class
Public Class Tiger
    Inherits Animal

    Public Property MeatEatingQuantity As Integer

End Class

In above code, you can see parent class as “Animal” and 5 child classes which are inheriting parent class. Not all animals have the same properties. Some animals sub classes have different properties. For example, Dairy milk producer animals have different properties than meat eater animals.

Now our platform is ready. I will show you two scenarios.

Scenario no. 1:

        Dim animals As New List(Of Animal)

        Dim oCow As New Cow
        oCow.Legs = 4
        oCow.AverageMilkQuantity = 15

        Dim oBuffalo As New Buffalo
        oBuffalo.Legs = 4
        oBuffalo.AverageMilkQuantity = 20

        Dim oCamel As New Camel
        oCamel.Legs = 4
        oCamel.AverageMilkQuantity = 25

        Dim oTiger As New Tiger
        oTiger.Legs = 4
        oTiger.MeatEatingQuantity = 5

        Dim oLion As New Lion
        oLion.Legs = 4
        oLion.MeatEatingQuantity = 7

        animals.Add(oCow)
        animals.Add(oBuffalo)
        animals.Add(oCamel)
        animals.Add(oTiger)
        animals.Add(oLion)

        'For Milk Producer '
        For Each oAnimal As Animal In animals
            Dim MilkQuantity As Integer = 0 

            If TypeOf oAnimal Is Cow Then
                MilkQuantity = DirectCast(oAnimal, Cow).AverageMilkQuantity
                
            ElseIf TypeOf oAnimal Is Buffalo Then
                MilkQuantity = DirectCast(oAnimal, Buffalo).AverageMilkQuantity
                
            ElseIf TypeOf oAnimal Is Camel Then
                MilkQuantity = DirectCast(oAnimal, Camel).AverageMilkQuantity
                
            End If

        Next

In this code, you can see in the last “For each” loop, we have to repeat the same stuff again and again unnecessarily. To solve this problem, we will create an Interface. We can create an abstract class, but it is unnecessary because we are not going to write any kind of implementation code. So the best solution is to create an Interface. Here is the Interface, changed child classes and changed “For each” loop.

Public Interface IMilkProducer
    Property AverageMilkQuantity As Integer
End Interface
Public Class Cow
    Inherits Animal
    Implements IMilkProducer
     
    Public Property AverageMilkQuantity As Integer Implements IMilkProducer.AverageMilkQuantity
     
End Class
Public Class Buffalo
    Inherits Animal
    Implements IMilkProducer
     
    Public Property AverageMilkQuantity As Integer Implements IMilkProducer.AverageMilkQuantity
     
End Class
Public Class Camel
    Inherits Animal
    Implements IMilkProducer
     
    Public Property AverageMilkQuantity As Integer Implements IMilkProducer.AverageMilkQuantity
     
End Class
 'For Milk Producer '
For Each oAnimal As Animal In animals
     Dim MilkQuantity As Integer = 0
     
     If TypeOf oAnimal Is IMilkProducer Then
         MilkQuantity = DirectCast(oAnimal, IMilkProducer).AverageMilkQuantity
     End If

Next


Isn’t it great? It reduced number of code lines of "For each" loop and makes the code easy to use and maintainable. Interfaces are like “plug and play” instrument. You can create interfaces with closely related properties or methods. Classes have to implement those interfaces to make code easy to use and maintainable.

Scenario no. 2:

Now imagine that you want to manipulate some methods of particular group like “MilkProducer”. When somebody request “getMilkQuantity”, you want to put some logic and then you want to return “MilkQuantity”. How will you do that? Here is the simple code, which will solve this issue.

Public Class MilkProducer
    Dim objMP As IMilkProducer

    Sub New(ByVal oMilkProducer As IMilkProducer)
        objMP = oMilkProducer
    End Sub

    Public Function getMilkQuantity() As Integer

        'Her You can manipulate '
        If TypeOf objMP Is Cow Then
            'This is just an example '
            objMP.AverageMilkQuantity = 10
        End If

        Return objMP.AverageMilkQuantity

    End Function
End Class
'For Milk Producer '
 For Each oAnimal As Animal In animals
     Dim MilkQuantity As Integer = 0
     
     If TypeOf oAnimal Is IMilkProducer Then
          Dim mp As New MilkProducer(oAnimal)

          MilkQuantity = mp.getMilkQuantity
          
     End If

Next


Isn’t it cool? Let me know if you have any questions. I will try my best to provide answers to your queries. I hope this will help you understand when and why we need to create Intefaces.

Wednesday, June 4, 2014

Explain Interfaces in .Net

Interfaces define the properties, methods, and events that classes can implement. Interfaces allow you to define features as small groups of closely related properties, methods, and events; this reduces compatibility problems because you can develop enhanced implementations for your interfaces without jeopardizing existing code. You can add new features at any time by developing additional interfaces and implementations. Interfaces cannot contain any implementation code or statements associated with implementation code

Click here to see when and why we need to create Interfaces

There are several other reasons why you might want to use interfaces instead of class inheritance:

• Interfaces are better suited to situations in which your applications require many possibly unrelated object types to provide certain functionality.

• Interfaces are more flexible than base classes because you can define a single implementation that can implement multiple interfaces.

• Interfaces are better in situations in which you do not have to inherit implementation from a base class.

• Interfaces are useful when you cannot use class inheritance. For example, structures cannot inherit from classes, but they can implement interfaces.

Tuesday, June 3, 2014

How to resize images using IHttpHandler?

Today we will see how to resize Images with IHttpHandler. Let’s put Image controls with three different sized images. Image will be same, but only sizes will be different.

<asp:Image ID="img" runat="server" ImageUrl="~/Desert.jpg?size=64" />
<asp:Image ID="Image1" runat="server" ImageUrl="~/Desert.jpg?size=164" />
<asp:Image ID="Image2" runat="server" ImageUrl="~/Desert.jpg?size=364" />

Here, you can see, I have passed sizes in querystring. Size=64 means I am requesting 64x64 size of that image. Now the next step is to make “ResizeImageHandler”. I am resizing image on the fly, means not storing anywhere. Just resizing image and throwing back to the response.
Note: requested image "Desert.jpg" must exist on your server, otherwise it will throw exception. I haven't handled exception because this is just example to understand IHttpHandler

Imports System.Drawing
Imports System.IO

Public Class ResizeImageHandler
    Implements IHttpHandler


    Public ReadOnly Property IsReusable As Boolean 
    Implements IHttpHandler.IsReusable
        Get
            Return True
        End Get
    End Property

    Public Sub ProcessRequest(context As HttpContext) 
    Implements IHttpHandler.ProcessRequest
         
        Dim req As HttpRequest = context.Request
        Dim res As HttpResponse = context.Response

        'Get the image file path '
        Dim path As String = req.PhysicalPath

        'Get the Image '
        Dim img As Image = Image.FromFile(path)

        'Image converter '
        Dim converter As New ImageConverter

        Dim s As Size
        If req.QueryString("size") IsNot Nothing Then

            'Get the size to Resize original image '
            Dim sz As String = req.QueryString("size")

            s = New Size(sz, sz)

            'Resize the original image to requested size '
            Dim bm As Bitmap = New Bitmap(img, s)

            'Convert to Image '
            Dim fImg As Image = bm

            'Write the Resized Image to browser '
            res.BinaryWrite(converter.ConvertTo(fImg, GetType(Byte())))
        Else

            'Write the original image '
            res.BinaryWrite(converter.ConvertTo(img, GetType(Byte())))
        End If
             
End Sub
 
End Class

Now, after creating class which implements IHttpHandler, we have to register it. I am using IIS 7 with Integrated Mode, so I have registered as below. There are different ways to register the Handler based on which IIS you are using and in which mode (classic/Integrated).
To know, which registration method you have to use, read this MSDN Article

<configuration>
  <system.webServer>
 <handlers>
    <add name="ResizeImageHandler" verb="GET"
           path="*.jpg"
           type="ResizeImageHandler"
           resourceType="Unspecified" />

 </handlers>
  </system.webServer>
</configuration>

Now it’s time to run the page with above Image server controls. After running that page, you will see following output.

Monday, June 2, 2014

HTTP Handlers and HTTP Modules Overview

An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler. You can create your own HTTP handlers that render custom output to the browser.

Click here to see IHttpHandler Example Code

An HTTP module is an assembly that is called on every request that is made to your application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life-cycle events throughout the request. HTTP modules let you examine incoming and outgoing requests and take action based on the request.

Click here to see IHttpModule Example Code

Scenarios:

Typical uses for custom HTTP handlers include the following:

RSS feeds To create an RSS feed for a Web site, you can create a handler that emits RSS-formatted XML. You can then bind a file name extension such as .rss to the custom handler. When users send a request to your site that ends in .rss, ASP.NET calls your handler to process the request.

Image server If you want a Web application to serve images in a variety of sizes, you can write a custom handler to resize images and then send them to the user as the handler's response.

Typical uses for HTTP modules include the following:

Security Because you can examine incoming requests, an HTTP module can perform custom authentication or other security checks before the requested page, XML Web service, or handler is called. In Internet Information Services (IIS) 7.0 running in Integrated mode, you can extend forms authentication to all content types in an application.

Statistics and logging Because HTTP modules are called on every request, you can gather request statistics and log information in a centralized module, instead of in individual pages.


Custom headers or footers Because you can modify the outgoing response, you can insert content such as custom header information into every page or XML Web service response.

Features:

HTTP handler and module features include the following:

• The IHttpHandler and IHttpModule interfaces are the starting point for developing handlers and modules.

• The IHttpAsyncHandler interface is the starting point for developing asynchronous handlers.

• Custom handler and module source code can be put in the App_Code folder of an application, or it can be compiled and put in the Bin folder of an application.

• Handlers and modules developed for use in IIS 6.0 can be used in IIS 7.0 with little or no change. For more information, see Moving an ASP.NET Application from IIS 6.0 to IIS 7.0.

• Modules can subscribe to a variety of request-pipeline notifications. Modules can receive notification of events of the HttpApplication object.

• In IIS 7.0, the request pipeline is integrated with the Web server request pipeline. HTTP modules can be used for any request to the Web server, not just ASP.NET requests.

React-select is very slow on larger list - Found solution - using react-window

 I had more than 4000 items in searchable dropdownlist. I have used react-select but it was very slow. finally I found complete solution to ...