Your SlideShare is downloading. ×
  • Like
  • Save
ASP.NET lecture 8
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

ASP.NET lecture 8


This lecture presents, …

This lecture presents,
Handlers and Modules
Deploying web application to IIS

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide
  • Successor of ISAPI extensions and filters.Interact with the Web server itself.Interact with low level processes, as the processing of incoming and outgoing HTTP requests.
  • Study ASP.NET request pipeline first
  • AppendMessage.cs
  • Difference between dynamic and static sites
  • Try changing ContentType
  • imageHandler.ashx
  • Note to add it to IIS it must be an assembly
  • Web.config: In all providers <clear/> first add applicationName


  • 1. ASP.NET 4.0Julie IskanderMSC. Communication and Electronics
  • 2. Lecture Outlines Handlers and Modules Deploying web application
  • 3. HttpHandlers andHttpModules
  • 4. HttpModules Simple classes that can plug themselves into the request- processing pipeline Attaching to events thrown by the application. Similar to Global.asax
  • 5. Global.asax HttpModules Store global state  Store global state between requests between requests Respond to application-  Respond to application- wide events wide events  A separate Specific application assembly, that can be referenced by any application  Implements generic functionality that’s useful between different applications.Global.asax vs. HttpModules
  • 6. Creating an HTTPModule Create a class implementing System.Web.IHttpModule interface Requires to implement : Init and Dispose ◦ Init:  Input parameter: HttpApplication context  Access current application context  To implement HttpModule functionality  Used to wire-up different events that fire during request processing
  • 7. Creating an HTTPModule ◦ Dispose:  called once when the application terminates.  Application terminates and reinitializes when:  The application or IIS restarts,  The Web.config configuration file or a dependent assembly is modified. Configure module in web.config
  • 8. Convert from an HTML to an aspx page
  • 9. ASP.NET features handled bymodules: Output Caching Session State Windows Authentication Forms Authentication Passport Authentication Role manager Anonymous Identification Profile ErrorHandlerModule
  • 10. HttpHandlers The last stop for incoming HTTP Request The point in the request processing pipeline that is responsible for serving up the requested content Mapped to a specific file extension (.aspx, .html,.jpg…………) Unlike modules, only one handler is used to process a request.
  • 11. Built-in HTTP HandlersHandler DescriptionASP.NET page handler (*.aspx) The default HTTP handler for all pages.Web service handler (*.asmx) The default HTTP handler for Web servicesGeneric Web handler (*.ashx) The default HTTP handler for all Web handlers that do not have a UI and include @WebHandler directive
  • 12. Creating HttpHandlers Using generic handler .ashx Mapping the HttpHandler to a custom file extension.
  • 13. Generic HttpHandlers Add new item Generic Handler (*.ashx) Class implements IHttpHandler ◦ ProcessRequest:  Actually process incoming HTTP request.  Input argument:  HTTPContext object has access to all objects of the current HTTP context as response, request, user, profile, …….. ◦ IsReusable:  Property to let ASP.NET know whether incoming HTTP requests can reuse the same instance of the HttpHandler
  • 14. Convert from an HTML to an aspx page
  • 15. HttpHandlers to custom fileextensions Create a class that inherit from IHttpHandler, add it to App_code or in a separate library project to be added as an assembly Implement the 2 methods same as previously Add configuration to web.config
  • 16. Convert from an HTML to an aspx page
  • 17. Deployment
  • 18. Publish on Local IIS Must run Visual Studio as Administration Install all needed IIS components Reinstall ASP.NET if needed Make sure application pool is set to .NET Framework 4.0 Add user(with permissions to db and files) to application pool identity
  • 19. Publish on Local IIS Use Copy Website Use Publish Website
  • 20. Important Note To avoid problems with configuration in machine root web.config ◦ Add <clear /> in all providers To avoid problems with users and roles in multiple applications add applicationName attribute to all providers
  • 21. Reading Assignment #8 Chapter 26 – Professional ASP.NET 4 in CS and VB
  • 22. REFERENCES [1] Beginning ASP.NET 4 In C# 2010, Matthew Macdonald, Apress [2] Web Application Architecture Principles, Protocols And Practices, Leon Shklar And Richard Rosen, Wiley [3] Professional AS P.NE T 4 In C# And VB, Bill Evjen, Scott Hanselman And Devin Rader, Wiley [4] Pro ASP.NET In C# 2010, Fourth Edition,matthew Macdonald, Adam Freeman, And Mario Szpuszta, Apress