Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Popular Tags...

Tags

SnowCovered Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

Recently Viewed...

Working with ASP.Net HTTPHandlers

Working with ASP.Net HTTPHandlers
 
ASP.Net is one of the most capable platforms for web development in existence today, and has everything that a dynamic website needs to grow and develop. A lot o ASP.Net functionality is built using the core features that .Net provides. A great example is ASP.Net MVC which is built over the existing ASP.Net insfrastructure but radically different from the classic ASP.Net programming model.
 
Imagine building something like ASP.Net MVC? Maybe not so complex, but something interesting that would handle a specialized extension and serve up some data with some special processing. With ASP.Net’s HTTPHandlers you can do that.
 
How Do HTTPHandlers Work
An HTTPHandler is the mechanism used by ASP.Net to process any file that is requested from it. In fact ASP.Net’s native .aspx pages are delivered using the same technology. When a HTTP Handler is registered with ASP.Net (using the web.config file), and appropriate settings are made in IIS then your server will start executing your HTTP Handler whenever a file of the extension you specified is requested from the server.
 
This lets you manipulate the output and return specially formatted data that can be displayed in a viewer friendly manner.
 
 
ASP.Net uses the ISAPI (Internet Server Application Programming Interface) to the connect to IIS and process the requests. The HTTPHandler is the shortest connection between IIS and ASP.Net. It does not carry any baggage of a page-request, headers or mime-types, so it can be used to deliver high performance data in any format – binary or html.
 
Setting up a HTTPHandler
Let’s consider an example scenario. Assume we’ve got a bunch of CSV files containing contacts data on our server and we want to create a Handler that lets the visitors view the CSV files in a tabular format. All the files on the server have the extension ‘.csv’. Let’s create a handler which does the job.
 
Step 1: Create a Class
Create a new class to contain our handler code. Let’s call this ‘Handler’.

Step 2: Alter the Web.Config file
We need to make the appropriate entries in the Web.Config file of our project so that ASP.Net will call our handler instead of sending the requested file to the browser.
 
<configuration>
 <httpHandlers>
    <addverb="*"path="*.csv"type="HTTPHandler.Handler, HTTPHandler"/>
 </httpHandlers>
</configuration>
 
This will route all requests to a CSV file to our handler. Let’s understand how this works
 
Verb – Which type of HTTP Request will this handler consume. You can use the asterisk wildcard (‘*’) if you want to handle all requests, or you can set it up only for specific verbs like ‘GET, POST’.
Path – The extension you want to capture.
Type – the class and the namespace of your handler code.
 
Step 3: Set up the handler in IIS
We’ve already told ASP.Net to call our handler code when it gets a request for our extension, but before ASP.Net can do that, we need to tell IIS to send all requests for the files to ASP.Net.
 
--> Load IIS
--> Right Click on ‘Websites’->’Your Website’ and choose Properties
--> Select the ‘Home Directory’ tab and click ‘Configuration’
--> In the Executable Section put a reference to the ASP.Net ISAPI DLL (get the path from the .aspx Application Extension already present
--> In the Extension field put in your custom extension (we’ve filled .csv) and click OK.
 
 
Coding the HTTP Handler
Now that we’ve set up our HTTP handler, let’s code it and get it working.
 
The HTTP Hander class we created must implement the IHttpHandler interface. This is a simple interface with two functions:
 
  • ProcessRequest
  • IsReusable
 
Th   IsReusable function decides whether the HTTP Handler instance can be used by multiple requests. This will return true in most cases.
 
ProcessRequest is the function that we are primarily concerned with. Our main code will reside here, and we will process the request, returning desired data from this function. Here’s the code we have written.
 
  public class Handler : IHttpHandler
    {
        #region IHttpHandler Members
 
        public bool IsReusable
        {
            get { return true; }
        }
 
        public void ProcessRequest(HttpContext context)
        {
            string file = context.Request.Url.Segments.Last<string>(); //Get the name of the page requested
 
            if (file.Substring(file.Length - 3).ToUpper() == "CSV") //Does this page have .csv extension
            {
                string txt = System.IO.File.ReadAllText(context.Server.MapPath(context.Request.Url.AbsolutePath)); //Load the file and read the text
                string[] lines = txt.Split(Environment.NewLine.ToCharArray()); //Split the file on the basis of lines
 
                HttpResponse res = context.Response;
 
                GetHeader(res); //Add the HTML header
                res.Write("<body>");
                res.Write("<table class='tbl'>");
 
                int iCount = 0;
                foreach (string line in lines) //Loop through each line of the csv and show it
                {
                    res.Write("<tr>"); //Start a new row
                    if (!string.IsNullOrEmpty(line)) //Skip empty lines
                    {
                        string[] cols = line.Split(','); //Split on commas
                        foreach (string col in cols)
                        {
                            res.Write("<td>"); //Start a new column
                            if (iCount == 0)
                            {
                                res.Write("<strong>"); //Make the headings bold (first item of the row)
                                res.Write(col.Trim()); //Write the contents of the column
                                res.Write("</strong>");
                            }
                            else
                                res.Write(col.Trim());
 
                            res.Write("<td>");
                        }
                    }
                    res.Write("</tr>");
                    iCount++;
                }
                //Close the HTML tags
                res.Write("</table>");
                res.Write("</body>");
                res.Write("</html>");
            }
        }
 
        ///<summary>
        /// Get the header for the HTML page
        ///</summary>
        ///<param name="res"></param>
        private void GetHeader(HttpResponse res)
        {
            //Add the headers along with our little CSS
            res.Write("<!DOCTYPE html>");
            res.Write("<html>");
            res.Write("<title>This is a CSV file</title>");
            res.Write("<style type='text/css'>body{}.tbl{border:solid 1px gray;} .tbl td{border-bottom:solid 1px gray;padding:3px;}</style>");
            res.Write("<head>");
            res.Write("</head>");
        }
        #endregion
    }
 
Here is the CSV Data that we’re processing in the sample project:
Name, Age, Phone Number
John Doe, 34, 2343434
John Smith, 23, 45080
Jane Doe, 45, 23555
Jane Smith, 65, 343444
Big Joe, 23, 3454533
Little Moe, 32, 545456
 
And this is the Output
 
We’ve written a complete web-page through code, including Doctype and HTML headers. While this is one possible use, you might be able to use it more often to return partial data of page, and binary data like custom images (ex., after you’ve watermarked them), etc.
 
If you read the code above you can see that our class Handler implements the interface IHttpHandler. Most of our code is in the ProcessRequest function.
 
Working with Context Object.
The ProcessRequest function gives us the HttpContext object (context), which has all the information we need to process the request and return the result. The HttpContext object has several objects like Request, Response, Session, Server, etc.
 
The Request object has details like the file requested, querystring, etc. You can also get additional information like request type, HTTP headers sent, etc., from this object.
 
The Server object has all your server information. In this example we use the MapPath function of the object to find the physical path of the file on the disk base on its Absolute URL path.
 
You can use the Session object to store any information that you want to manage on the server. The most popular usage is to keep user login information which can be used to make sure that your user is authorized to view the content they are requesting.
 
The Response object is used to send your data to the client. This data can be text, image, sound, video or any other file. You can set the mime-type to a suitable format depending on the data you send. If you are sending plain text or HTML content you can go with the default values. The function we use to send the data to the client is Response.Write(). You must have used this in your regular ASP.Net files earlier.
 
Conclusion
This concludes our little tutorial on HttpHandlers. Now you’re ready to use this powerful technique to serve custom and binary content to your visitors.
 
If you don’t need to serve data based on specific file formats, you can use ashx (HTML Handler) files to get the advantage of faster processing (no page-cycle) to serve custom content to your viewers. To do this you just need to create an ashx file and implement IHttpHandler. Your content will be available only when a visitor requests your ashx file. 
 
If you want to download the "IHttpHandler Sample Project.zip" file for this article, please REGISTER first.
 
 

Share the page?

Working with ASP.Net HTTPHandlers  - share this page - email email - del.icio.us del.icio.us - digg digg - reddit reddit

Feedback Comments

Feedback

SharePoint Web Parts


All Data Springs Web Parts Support WSS 3.0, SharePoint 2007, and SharePoint 2010 Frameworks

Please select license option for each web part you wish to purchase. We highly recommend the SharePoint Bundle to get all Data Springs Web Parts for maximum value!

 

 

      
Cart


Data Springs Sharepoint Bundle

Best Value! The Bundle gives you all 5 web parts in one package at a very attractive price! Best Value! We think you will be very happy with the SharePoint bundle and great price discounts you will receive. With your purchase all of the web parts below will be included.
 
 
 
 

Random Image Web Part

With Random Image for Sharepoint 2007, you can select multiple images to display randomly when the web part loads...
 
 
 
 

Stock Quote Web Part

Giving your site visitors relevant information is critical. With the Data Springs Stock Web Part you can provide your users with up to date financial information
 
 
 
 

Dynamic Image Rotator Web Part

Who would have thought? Adobe Flash® with Sharepoint! The FIRST and ONLY image rotation web part for Sharepoint using Flash Technology from Adobe! The Dynamic Image Rotator displays selected images and then rotates between the images. Several extended and optional features allow you to select the time to rotate each image, fade between
 
 
 
 

SharePoint Charts Web Part

The MOSS Chart Web Part is a web part built by Data Springs for the purpose of rendering several chart types based on data from a SharePoint list on a MOSS 2007 or WSS 3.0 Site
 
 
 
 

Dynamic News Ticker Web Part

Provide current news items with a user-friendly news ticker for your Sharepoint Portal. With millions of web sites offering information you need a fun way to display information and the solution is Flash News Ticker....
 
 
 
 

Tailored Text Web Part

 Tailored Text Web Part allows you to add text/html to your web site that can be different for anonymous users, registered users,  and even individual users specifically.

 
 
 
 

Dynamic Views Web Part

Dynamic Views is an excellent tool to:
Personalization allows you to go the extra mile in communicating or connecting one to one with your clients. When it comes to technology and web site content, you now have the power to leverage this personalization directly with your users on your DotNetNuke® site

 
 
 
 

Dynamic Login Web Part

Your site content isn't vanilla, so why is your portal's login?

Add pizazz and functionality with Dynamic Login! Use custom templates, localization, redirection rules for various roles and many more features!
 
 
 
 


DNN Modules

DotNetNuke Modules


Data Springs offers cost-saving packages that fit your needs:

Purchase the Collection 6.0

Data Springs Collection 6.0

An entire tool chest to quickly build websites and construct complex, powerful, and relevant workflow. Elevate your design with custom registration, forms, displays, reports, user management, payments, Google maps,, SQL updates, and so much more!

Best Value!  Includes all DotNetNuke modules by Data Springs.

$ 495.00

Data Springs User Management Suite 3.0

All the tools you need to enhance user & profile management from A to Z!.  A comprehensive package with 5 feature-packed modules that offer extensive admin controls and easy user interface geared towards an effective and growth-oriented site!  .... more

 

Includes:  Dynamic Registration     Dynamic Login   ♦   Interactive User Import     Dynamic User Directory   ♦   Renewal Reminder    A value of more than $630.00!

 $ 369.00

 

 

Check out all our individual modules!

 

 View Dynamic Registration

Dynamic Registration 5.0 (new release on 6/12/2013)

Need custom fields and workflow for your registration? Get all the power and ease of use to create the registration and profile management just the way you want it... more

$ 199.00

View Dynamic Forms

Dynamic Forms 4.1 (released 5/16/2012)

Whether it's for marketing, sales, contact forms, scheduling, information requests, surveys, or to simply better understand your customer needs, the possibilities for creating powerfully effective forms are now easy and endless! ... more

$ 195.00

 

Dynamic Views 3.1 (new on 2/7/2013)

Now have an easy yet feature-rich reporting module with custom defined display templates and unlimited search options from  Dynamic Forms or any data source like a table, view or custom query!  ... more

$ 169.00

 View Dynamic Login Module

Dynamic Login 4.1 (released 10/19/2011)

Add pizazz and functionality to your site login! Dynamic Login gives you custom templates, localization, redirection rules, SQL Validation, and Single SignOn. Want more? How about Facebook Connect, LinkedIN, and Twitter, too? Your login has never been so exciting!.   ... more

$ 149.00

 View Interactive User Import

Interactive User Import 3.0 (released 8/17/2011)

Interactive User Import provides you with the functionality to easily and quickly import users into DotNetNuke and Dynamic Registration, through a streamlined and well-documented wizard that includes many advanced features... more

$ 149.00

 View Dynamic User Directory

Dynamic User Directory 4.1 (released 4/26/2012)

The perfect compliment for extending your portals users and community! An essential ingredient for managing dynamic user information, is being able to sort key fields and create useful user directories and custom report information... more

$ 179.00

 View Renewal Reminder

Renewal Reminder 1.3

Renewal Reminder provides you with the functionality to setup email notifications for users that their security role will soon expire. After installing your renewal / security role reminder module you can now setup scheduled notifications to be distributed to your users... more

$ 129.99
 View Opt In Email

Opt In Email 5.0 (new on 4/17/2013)

'Relationship Building' and 'Communication' are two essential nuts and bolts for a business to prosper. This module allows you to bridge both of these and easily generate continuous awareness of your web site, products and services. Your prospects and customers will greatly appreciate this feature... more

$ 179.00

 View Tailored Text

Tailored Text 3.0

Personalization allows you to go the extra mile in communicating or connecting one to one with your clients. Leverage the power personalized content on your DotNetNuke site... more

$ 109.99
 View Stock Quote

Stock Quote 1.2

Giving your site visitors relevant information is critical. With the Data Springs Stock Module you can provide your users with up to date financial information... more

$ 109.99
 View Presentation Archive

Presentation Archive 2.0

With so much content on your web site, its important to give users an easy method for finding and retrieving content. Presentation Archive allows you to categorize, organize and present content within your DotNetNuke site for presentations, educational material, videos, and almost any document... more

$ 124.99
 View Real Estate

Real Estate 2.3

Real Estate 2.3 is a feature rich and user-friendly module that allows your portal users the ability to create real estate listings on your site... more

$ 149.99
 View Dynamic Image Rotator

Dynamic Image Rotator 3.3

Dynamic Image Rotator displays selected images and then rotates between the images using the Adobe® Flash® platform.  Several extended and optional features allow you to select the time to rotate each image, fade between images, and also display the images in either sequental or random order... more

$49.99
 View Info Pics Gallery

Info Pics Gallery

The Info Pics Gallery Module allows you to display thumbnail pictures with information to the user about each picture, along with a detailed description regarding the set of pictures and several other optional links... more

 $ 69.99
 View Testimonials Module

Testimonials

The Testimonials Module allows you to display customer testimonials on your site, as well as an easy method for users to submit testimonials about your web site, services, or products... more

 $ 49.99
 View Dynamic Info Cube

Dynamic Info Cube

Take your web site out of the box! Looking for a creative and interesting way to showcase information and content on your site? With millions of web sites offering information you need a fun way to display information and the solution is Dynamic Info Cube... more

$ 99.95
 Search Engine Optimization Cloud Module for DotNetNuke

Dynamic Tags

Nearly every web site developer would agree that search engine optimization is one of key aspects to a successful web site. Part of search engine optimization requires providing search engines that crawl your web site with appropriate and meaningful content... more

$ 69.99
 View Page Tags

Page Tags

'Page Tags' pulls in search terms that users searched to find the current page. There are many benefits to displaying these search words that delivered the user to the site, find our more details ... more

$ 59.99
 Random Rounded Images

Random Rounded Images

Random Rounded Images is an easy to use upgraded version of the images module included with DNN. With RRI, you can select multiple images to display randomly when the module loads. For example, you can add 10 images to the module, and each time you refresh or load the page one of those images will... more

$ 49.99
 View Back on Track

Back on Track

Giving your site visitors fast access to areas of interest is vital to your web site's ease of use and ultimately - sales potential... more

$ 99.99
 

Dynamic News Ticker 2.0

Dynamic News Ticker allows you to scroll through news items in a horizontal or veritical direction with administrative features that allow you to easily customize the look of your news ticker. Each instance of Dynamic News Ticker can be set up to have different sizes, scroll directions, scroll speed... more

$ 39.00
 View Quick Poll

Quick Poll

Give your users a voice, while also providing an important way for you to gather opinions from your users and measure visitors' responses to questions on your site! Polls are significant because they can provide a way for your web site visitors to share ideas and vote on topics of your choosing... more

$ 39.99
 View Flash Contacts

Dynamic Contacts 2.0

Dynamic Contacts is the fastest and easiest way you can help visitors of your website connect with your key personnel... more

$ 79.99
     

 

 

 
 

Join our mailing list...

Get current news and events the easy way
Subscribe Me

Recent Blogs...

 
Copyright 2005 - 2011 by Data Springs, Inc.
 
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi