ASP.NET 4.0Julie IskanderMSC. Communication and Electronics
Lecture Outlines Handlers and Modules Deploying web application
HttpHandlers andHttpModules
HttpModules Simple classes that can plug  themselves into the request-  processing pipeline Attaching to events thrown b...
Global.asax                 HttpModules Store global state           Store global state  between requests              b...
Creating an HTTPModule Create a class implementing  System.Web.IHttpModule interface Requires to implement : Init and  D...
Creating an HTTPModule    ◦ Dispose:      called once when the application terminates.      Application terminates and r...
Convert from an HTML to an aspx page
ASP.NET features handled bymodules: Output Caching Session State Windows Authentication Forms Authentication Passport...
HttpHandlers The last stop for incoming HTTP  Request The point in the request processing  pipeline that is responsible ...
Built-in HTTP HandlersHandler                         DescriptionASP.NET page handler (*.aspx)   The default HTTP handler ...
Creating HttpHandlers Using generic handler .ashx Mapping the HttpHandler to a custom  file extension.
Generic HttpHandlers Add new item Generic Handler  (*.ashx) Class implements IHttpHandler    ◦ ProcessRequest:      Ac...
Convert from an HTML to an aspx page
HttpHandlers to custom fileextensions Create a class that inherit from  IHttpHandler, add it to App_code or in  a separat...
Convert from an HTML to an aspx page
Deployment
Publish on Local IIS Must run Visual Studio as  Administration Install all needed IIS components Reinstall ASP.NET if n...
Publish on Local IIS Use Copy Website Use Publish Website
Important Note   To avoid problems with configuration    in machine root web.config    ◦ Add <clear /> in all providers ...
Reading Assignment #8   Chapter 26 – Professional ASP.NET 4    in CS and VB
REFERENCES [1] Beginning ASP.NET 4 In C# 2010, Matthew  Macdonald, Apress [2] Web Application Architecture  Principles, ...
ASP.NET lecture 8
ASP.NET lecture 8
ASP.NET lecture 8
ASP.NET lecture 8
ASP.NET lecture 8
ASP.NET lecture 8
ASP.NET lecture 8
ASP.NET lecture 8
ASP.NET lecture 8
ASP.NET lecture 8
Upcoming SlideShare
Loading in …5
×

ASP.NET lecture 8

1,633 views

Published on

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

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,633
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

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 &lt;clear/&gt; first add applicationName
  • ASP.NET lecture 8

    1. 1. ASP.NET 4.0Julie IskanderMSC. Communication and Electronics
    2. 2. Lecture Outlines Handlers and Modules Deploying web application
    3. 3. HttpHandlers andHttpModules
    4. 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. 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. 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. 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. 8. Convert from an HTML to an aspx page
    9. 9. ASP.NET features handled bymodules: Output Caching Session State Windows Authentication Forms Authentication Passport Authentication Role manager Anonymous Identification Profile ErrorHandlerModule
    10. 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. 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. 12. Creating HttpHandlers Using generic handler .ashx Mapping the HttpHandler to a custom file extension.
    13. 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. 14. Convert from an HTML to an aspx page
    15. 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. 16. Convert from an HTML to an aspx page
    17. 17. Deployment
    18. 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. 19. Publish on Local IIS Use Copy Website Use Publish Website
    20. 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. 21. Reading Assignment #8 Chapter 26 – Professional ASP.NET 4 in CS and VB
    22. 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

    ×