English 中文(简体)
什么是进入顶点?
原标题:what is the main point to enter in asp.net?
  • 时间:2011-03-01 14:49:58
  •  标签:
  • asp.net

Like in java the entry point is public static void main(String[] args). What is the entry point in ASP.NET using C#? Usually, I see the page load method, is that the entrance point?

对应标准是否不同?

最佳回答

你说了一些错误。

您不妨比较服务器/JSP和ASP。 NET, no t You?

Servlets vs IHttpHandler

从概念上讲,它们是相同的。 它们也是两个接口。 其配置有所不同(WEB.xml VS Web.config或.ashx文档),但其切入点“几乎”相同。

Servlet:

Init()
Service()
Destroy()

IHttphandler:

ProcessRequest() <<--- does all the things
IsReusable {get;} <<--- optional

JSP vs ASP.NET pages

如果你界定了一种构造,或者推翻了<代码>InitializeFramework()方法,那么,你就有一个起点(或者至少是一分点,可以把执行放在几乎一切的想象中),但不是切入点。

Page class implements IHttpHandler, if you allow me some Java syntax in .NET world, but you don t see anything. You might want to go deeper into page life cycle as linked by other users. Basically explaining, Page encapsulates its complete life cycle in events, that resemble clock ticks when you work with VHDL components.

Execution is not concurrent as it seems, but since you can t know the exact order in which controls will raise the same event, you can go as the VHDL example in which you can t read the value of a registry before the next clock tick.

There are several events: here are the most important in their execution order

  • Init: page is initialized, GET, POST and cookie data are available. If you override, then you should initialize your webapp context (ie setup db connections)
  • Load (PreLoad and LoadComplete too): page loads the UI data and restores, if needs to, the state of controls displayed on the page. If you set up DB connections in init, you shouldn t use them before PreLoad to be sure you don t get an exception. The same applies to sequence PreLoad->Load->LoadComplete.
  • DataBind: data-bound controls load data from database, file or whatever (ie. tables get the data to display)
  • Validation: if you use validators, their business logic is processed to determine whether the page is valid or not. No further explaining here
  • Postback processing: if you click a button, then its server-side code is executed
  • PreRender (and PreRenderComplete): the page is getting ready for being rendered into HTML. Usually stores internal data into a collection named ViewState which I won t explain any further here. Usually you would finalize some data-related operations and/or decide whether to render or not some controls on the page according to the page s state. For example, if you have a CAPTCHA and the user solved the puzzle, you won t render it again
  • Render: not actually a programmatic event, but the page gets rendered to HTML
  • Dispose: resources get freed, as occurs with Destroy in Java
问题回答

如同p.net没有“主要点”。 你认为“主人”是已经写给你的法典。 相反,你继承了一个基类(“Page”)。 作为这项工作的一部分,你可以(但不必)执行若干活动处理者。 通过建立一个网页,Asp.Net将为你提供这些活动。 举办这些活动的过程称为page life/a>。

对于你来说,根据你想要采取的主要方法,有若干选择:

  • Handle the Application_Start event in the Global.asax file
  • The Page_PreInit event (the very first event in the page life cycle)
  • The Page_Load event (the most common event handled in the page life cycle)




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签