I have just started working on ASP.NET 2.0 again after a long long time. Its been almost an year since I did some serious coding and I want to get myself updated with the latest - asp.net 2.0.
I decided to use the Core ASP.NET reference book from MS Press and have been going through fundas like the IIS 6.0 Process model, HttpRuntime queue and so on.
How to detect the browser programatically in ASP.NET?
---------------------------------------------------------
You have the Request object with you. You can access the Request object either directly or from the HttpContext object. To detect the browser you are running ....
Dim browser as String = HttpContext.Current.Browser.Browser
For IE, browser would be "IE" and for firefox, its Firefox.
More about the HttpContext....
Actually, ProcessRequest method is called on the HttpRuntime object when a request arrives. Just before it serves a page to the request, a "context" is created which could be accessed through the HttpContext object. The HttpRuntime object uses the HttpContext object to locate or create a Web App object that is capable of handling a request it gets. There is an internal object that will be used to do the search - HttpApplicationFactory which maintains a pool of HttpApplication objects to serve incoming http requests. The HttpApplication is the base class that represents a running ASP.NET application. It is this object that determines what kind of a handler is needed - basically it decides what kind of resource is being requested - whether its a web page being asked for or a web server or a server control, etc.
Page Class and important members
-----------------------------------
The following is the list of important members of the Page class.
- Application - instance of HttpApplicationState
- Cache - instance of Cache class, implements cache for an asp.net application
- Request - instance of HttpRequest
- Response - instance of HttpResponse
- Server - instance of HttpServerUtility, helper method for processing web requests.
- Session - instance of HttpSession.
- Trace - instance of TraceContext, used for tracing.
- User - represents the current user whose request is being processed.
There is also a Context object that could be used ( it holds for HttpContext.Current).
From my past experience coding ASP.NET web apps, one most important thing that a newbie should always learn is the Page life cycle. By Life cycle in an application programming model, we basically mean what events are fired at what time. The ordering of events become very essential especially when the application grows. Knowing where to put initialization code, where to add controls dynamically, etc will help us code better applications.
The ASP.NET Web Page life cycle is given below.
- PreInit
- Init
- InitComplete
- View State is now restored
- Posted data is processed
- PreLoad event is fired
- Load event is raised
- LoadComplete (in between few events for handling postback is taken care of)
- PreRender
- PreRenderComplete
- SaveStateComplete
More information is given here
ASP.NET 2.0 Page Life cycle
http://www.robincurry.org/blog/content/binary/o_aspNet_Page_LifeCycle.jpg
I will post more as I get deep into the subject. I plan to devote an hour a day once the spring break is over.
This is what I think I will/should be doing
1. Core ASP.NET 2.0
2. Data binding with ASP.NET 2.0 and ofcourse ADO.NET
3. ATLAS / ASP.NET AJAX.
Then may be I can get hands-on with XAML,WPF,WCF,Windows Workflow...Gosh there is a lot to learn....