Category Archives: ASP.Net

ASP.Net

O arquivo machine.config

Por padrão, todos os directório são herdados de um arquivo de configuração padrão de sistema chamado de machine.config, (localizado em: “WinNT\Microsoft.NET\Framework\Versão\CONFIG“).

ASP.Net

O arquivo Global.asax

O arquivo Global.asax opera de maneira semelhante as páginas *.aspx. Você utiliza o Global.asax para sincronizar qualquer evento exposto pela classe HttpApplication. Eventos quais veremos abaixo:

Evento Descrição
AcquireRequestState Accionado quando o Aplicativo obtém o cache para a solicitação.
AuthenticateRequest Accionado quando o Aplicativo tenta autenticar a solicitação de HTTP.
AuthorizeRequest Accionado quando o Aplicativo tenta autorizar a solicitação de HTTP.
BeginRequest Accionado quando a solicitação de HTTP é iniciada.
EndRequest Acionado quando a solicitação de HTTP é concluída.
Error Acionado quando surge um erro.
PostRequestHandlerExecute Accionado imediatamente depois do handler de HTTP processar a solicitação.
PreRequestHandlerExecute Accionado imediatamente antes do handler de HTTP processar a solicitação.
PreSenderRequestContent Se a solicitação tiver conteúdo adicional (QueryString, Variáveis de Formulário, etc.), esse evento é acionado imediatamente antes daquele conteúdo ser recebido.
PreSenderRequestHeaders Accionado imediatamente antes de os cabeçalhos de solicitação serem recebidos.
ReleaseRequestState Accionado quando o Aplicativo libera o estado de sessão para a solicitação.
ResolveRequestCache Acionado quando o Aplicativo determina o cache para a solicitação.
UpdateRequestCache Accionado quando o Aplicativo autaliza e libera o cache para a solicitação.

——————————-
——————————-

Imports System.Web

Imports System.Web.SessionState
Public Class Global

Inherits System.Web.HttpApplication
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)

‘…

End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)

‘…

End Sub
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)

‘…

End Sub
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)

‘…

End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

‘…

End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)

‘…

End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)

‘…

End Sub

End Class

——————————-

Código 1 – O arquivo Global.asax.

ASP.Net

ASP.NET supports two methods to author pages:

  • In-line code is code that is embedded directly within the ASP.NET page.
  • Code-behind refers to code for your ASP.NET page that is contained within a separate class file. This allows a clean separation of your HTML from your presentation logic.

When we use Microsoft Visual Studio .NET to create ASP.NET Web Forms, code-behind pages are the default method. In addition, Visual Studio .NET automatically performs precompilation for us when we build our solution.

A little bit of background
Directives in ASP.NET control the settings and properties of page and user control compilers. They can be included anywhere on a page, although it is standard to place them at the beginning. Directives are used in both .aspx files (ASP.NET pages) and .ascx files (user control pages). ASP.NET pages actually support eight different directives.
* @ Page

* @ Control

* @ Import

* @ Implements

* @ Register

* @ Assembly

* @ OutputCache

* @ Reference
Page directives are the most commonly used directives, and are used to edit a wide variety of settings that control how the page parser and page compiler work. The following is a list of some of the more commonly used page directive attributes in ASP.NET.
@ Page language=”c#” Codebehind=”WebForm1.aspx.cs”

AutoEventWireup=”false” Inherits=”TestWebApp.WebForm1″

  • Language indicates the language in which the inline script code within the ASP.NET page is written (the code between tags). The value of this attribute can be C#, VB, or JS.
  • Codebehind indicates the name of the file being used as the code supporting this ASP.NET page. This file should reflect the Language setting; that is, if the language being used is C#, the CodeBehind file should have a .cs extension and be written in C#.
  • Inherits indicates a qualified class from which this ASP.NET page should inherit. Generally, this will be the name of the class described in the code-behind file.
  • AutoEventWireup is a Boolean attribute that indicates whether the ASP.NET pages events are auto-wired.

Note: In the above case, ASP.NET compiles the code-behind page on the fly. We have to note that this compilation step only occurs when the code-behind file is updated. Whether the file has been updated or not, well this is detected through a timestamp change.

To get to the Real Thing
The AutoEventWireup attribute may have a value of true or false. When an ASP.NET Web Application is created by using Microsoft Visual Studio .NET, the value of the AutoEventWireup attribute is set as false.
We can specify the default value of the AutoEventWireup attribute in the following locations:

  • The Machine.config file.
  • The Web.config file.
  • Individual Web Forms (.aspx files).
  • Web User Controls (.ascx files)

The value of the AutoEventWireup attribute can be declared in the

section in the Machine.config file or the Web.config file.

ASP.Net

ASP.NET 2.0 Master Pages

ASP.NET 2.0 introduces a new concept known as Master Pages, in which you create a common base master file that provides a consistent layout for multiple pages in your application. To create a Master Page, you identify common appearance and behavior factors for the pages in your application, and move those to a master page. In the master page, you add placeholders called ContentPlaceHolders where the content (child) pages will insert their custom content. When users request the content pages, ASP.NET merges the output of the content pages with the output of the master page, resulting in a page that combines the master page layout with the output of the content page. In this article, you’ll take a look at the theory behind the master pages and see how to leverage the new Master Pages feature in a Web application. Along the way, you’ll also see some of the advanced concepts of master pages, such as accessing master page controls from code in content pages, nesting master pages, and configuring master page for an entire Web application.
http://www.devx.com/dotnet/Article/18042

ASP.Net

Three kinds of server controls

ASP.NET has solved the “spaghetti-code” problem described above with server controls.

Server controls are tags that are understood by the server.
There are three kinds of server controls:
* HTML Server Controls – Traditional HTML tags

* Web Server Controls – New ASP.NET tags

* Validation Server Controls – For input validation

ASP.Net IIS

Win XP Pro and IIS 5.1 Issues with .net Framework 2.0

I installed the new beta of .net framework and my asp stopped responding. I

don’t know what to look for and turn back on so that I can get asp to start

working again. Has anyone else had this issue? Have you corrected it and how?
From the command line

1) CD to the C:\Windows\Microsoft.Net\Framework\v1.14322

2) Type the command: aspnet_regiis -r
This will install/apply the ASP.NET 1.1 script engine.