ASP.NET request lifecycle confusion

≡放荡痞女 提交于 2019-12-08 03:11:56

问题


I am new to C# and .Net and am coming from a Java background. I am trying to get my head around the .NET way of doing web applications and am not having much luck.

I want to build an application to handle requests urls and write responses that return images. Having only used Java servlets in the web application field I am after some good resources and/or explanations on handling the request side of the application.

How are requests handled? and with what Objects? What is the cycle? how do pages function around this?

These are basic broad questions so if anyone knows of resources that covers them all thoroughly please let me know. What I have found so far has bits of information not the overall picture.


回答1:


The overall page cycle is complex - but for serving images, you may want to look primarily at the IHttpHandler interface - or (more simply) create a "generic handler" (.ashx file). The IHttpHandler is the simplest "request/response" setup, without the burden of .aspx pages; you simply read from the context.Request, and write to the context.Response.




回答2:


FOr serving up just image have a look HttpHandlers.

As for Page life cycles: I love this image:
(source: eggheadcafe.com)




回答3:


This overview will explain the Page life cycle, Page (an ASPX page) being the default HTTP handler in ASP.NET.

But there are other ways to handle HTTP calls. This resource will explain how .NET can handle HTTP calls, and how ASPX Pages handle them by default.

cheers




回答4:


This is a good place to start for a description of the page lifecycle.

For your other questions, I'd actually recommend you get a book and sit back for a few hours with it. Programming ASP.NET 2.0 Core Reference has proved itself very valuable.




回答5:


The site asp.net contains a lot of information to get you started. A good starting point is the learning section.

MSDN has lots of information, of course. A couple articles and pages you may find interesting: - ASP.NET Page Lifecycle Overview - Creating ASP.NET Web Pages

When reading the texts on MSDN, check the tree structure to the left for more content.



来源:https://stackoverflow.com/questions/924422/asp-net-request-lifecycle-confusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!