views:

228

answers:

3

I am in the process of learning ASP.NET MVC and I am learning it by walking through nerd dinner application.

I am having trouble understanding the ASPX and ASCX files. The way of writing the code in ASPX files seems pretty weird (code is split in multiple lines).

Please can you suggest any online tutorial/guide/article which can explain how to write ASPX pages?

EDIT:

Another question: When a variable like "Request" of type HttpRequest is used in an aspx page, where does it come from? I mean where is the class, where is the variable declaration?

+1  A: 

Request is type of HttpRequest, which is normally a static object across the single Request: ie, it is created each time in every Http Request made by the client.

Since all aspx page, is inherited from Page Class. Like:

public class Default : Page {..}

The Request Property is defined in the Page class, same as other like Response, Context etc. (and it is the same case for ascx, which parent is UserControl). They can all accessed through HttpContext.Current (which return the single-instance of context), but they defined in Page or usercontrol class for easier access.

xandy
A: 

Regarding the Request - it is a property of the Page class. Your ASPX page derives from Page class. Hence it has access to the property of the page class.

Request is constructed with all parameters that were sent by user by means of HTTP, which gets constructed by ASP.net for you to use it in a strongly typed fashion. In classic ASP, people had to write Request.SeverVariables(...) etc.

shahkalpesh
+1  A: 

The first chapter of "Professional ASP.NET MVC 1.0" is free. This chapter will take you through creating the Nerd Dinner application. A copy of the first chapter is available from: http://aspnetmvcbook.s3.amazonaws.com/aspnetmvc-nerdinner_v1.pdf. Running through the tutorial should make getting up to speed a lot easier.

ahsteele