ASP.NET

ASP.NET


ASP Master Page<%@ Master Language="C#" AutoEventWireup="true" CodeFile="SiteTemplate.master.cs" Inherits="SiteTemplate" %>
Content Page<%@ Page Language="C#" MasterPageFile="~/SiteTemplate.master" ... %>
 <asp:ContentPlaceHolder id="TitleContent" runat="server"> </asp:ContentPlaceHolder>
HttpHandlerIHttpHandler, ProcessRequest(System.Web.HttpContext context), IsReusable
HttpModuleIHttpModule, Init(HttpApplication app),
app.BeginRequest += new EventHandler(this.OnBeginRequest);
WebGardenIn IIS 6,Application Pools are created.If number of WorkerProcess permitted for service request is greater than 1 then it called WebGarden. Round-robin, Least Active, Fastest Reply
Levels of SecurityAuthentication, Authorization, Confidentiality, Integrity
ASP.NET Security ArchitectureApplication : BeginRequest, AuthenticateRequest, PostAuthenticate Request, Authorize Request, Post Authorize Request, Acquire Request State
AuthenticatonWindows, Forms, Passport, Custom
Impersonation is the process of executing code in the context (or on behalf) of another user identity
Forms AuthenticationTicket-based (also called token-based) system. <authentication mode="Forms">
<forms loginUrl="Login.aspx"> </forms>
<location path="salesPages">
 
<system.web>
   
<authorization>
     
<allow roles="sales" />
     
<deny users="*" />
   
</authorization>
  
</system.web> </location>
FormsAuthentication.Authenticate(UsernameText.Text, PasswordText.Text)
HttpCookie AuthCookie;
AuthCookie = FormsAuthentication.GetAuthCookie(UsernameText.Text, true);
AuthCookie.Expires = DateTime.Now.AddDays(10);
Response.Cookies.Add(AuthCookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(UsernameText.Text, true));
 
 

Windows Based Authentication
Basic AuthenticationWeb browser displays a login dialog box for user name and password.Credentials  are transmitted between the client and server as clear text
Digest AuthenticationPasses a hash of the password,
Integrated Windows AuthenticationBoth the client and the web server must be on the same local network or intranet Most convenient authentication standard for WAN-based and LAN-based intranet applications.
It performs authentication without requiring any client interaction
Authentication information is either NTLM (NT LAN Manager) authentication or Kerberos 5
<configuration> <system.web> <authentication mode="Windows"/> </system.web> </configuration>
Worker process EXEIIS 5.0 - aspnet_wp.exe, IIS 6.0 - w3wp.exe, OutProcess - ASPNet_State.exe, SQL Server aspnet_regsql
TracingASP.NET collects trace information for each request to the application which can be viewed in trace viewer. Web.Config : <trace enabled="true" pageOutput="false" requestLimit="40" localOnly="false"/>
< %@ Page Trace="true" %>
File :trace.axd in web app path
 

@Page DirectiveAspCompat, Language, AutoEventWireup, CodeFile, Title, Culture, UICulture, ValidateRequest, Theme, SmartNavigation,
MasterPageFile, EnableViewState, ErrorPage, Inherits
@Master DirectiveLanguage, AutoEventWireup, CodeFile, Title, MasterPageFile, EnableViewState, Inherits
@Control DirectiveLanguage, AutoEventWireup, CodeFile, EnableViewState, Inherits,  Debug, Src
@Register DirectiveAssembly, Namespace, Src, TagName, TagPrefix
@Reference DirectiveControl, Page, VirutalPath
@PreviousPageType DirectiveTagName, VirutalPath
@OutputCache DirectiveDuration, Location, VaryByParam, VaryByControl, VaryByCustom, VaryByHeader



 

Finalize method in .NETObject.Finalize, Garbage Collector
DISPOSE methodDispose method belongs to ‘IDisposable’ interface. Call GC.SuppressFinalize(this) in destructor of the class.
Page Life CycleInit - LoadViewState - Load - Render - Unload
EnableViewStateMACEncoded and encrypted viewstate is checked to verify that it has not been tempered with on the client machine
Master Page In Master page : <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
In Child Page : In Page directive MasterPageFile="~/Site.master"
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
System.Text.StringBuilderStrings are immutable (new object every time), StringBuilder are mutable
Localization and GlobalizationGlobalization is process of identifying how many resources needs to be localized to adopt a multiple culture support, while Localization is actual process of translating resource to a specific culture. So Localization is the part of Globalization.
(1) Tool -> Generate Resource
(2) <asp:Button ID="Button1" runat="server" Text="Hello"    meta:resourcekey="Button1Resource1" />
(3) Resource File with .resx extension is created
(4) For French aspx.fr.resx
(5) Need to set the Language Priority in IE Settings
Callbacks and PostbackCallback : It is a way to send a request to the web page from the client script. Postback is an expensive call with processing overhead. In callback a client function sends a request and a special marked method is invoked on the
server. It does the processing & returns the value which is received by another client function to process the result. To have client side callbacks, the page has to implement ICallbackEventHandler & implement functions RaiseCallBackEvent & GetCallBackResult.


PostBack: Postback is the event which sends the form data to the server. The server processes the data & sends it back to the browser. The page goes through its full life cycle & is rendered on the browser. It can be triggered by using the
server controls.
Mail1)SmtpClient 2)MailMessage 
UniqueID and ClientIDBoth the properties are associated with asp.net control. The difference is Unique ID has '$' (Dollar) sign and Client ID adds '_' (hyphen) to the control, if master page is used.

Let's say you have placed a text box called 'txtName' in content place holder. So client ID will be ct100_ContentPlaceHolder1_txtName where Unique ID will be ct100$ContentPlaceHolder1$txtName.

ClientID is used to access control in Java Script where using Unique ID you can make a post back using java script __doPostBack() function. 
Lamda ExpressionsA lambda expression is an anonymous function that you can use to create delegates or expression tree types.
Session State
SQL Server
Utility aspnet_regsql.
-S <server>       SQL Server instance (SQL Server 7.0 and above) to work with.
-U <login id>     SQL Server user name to authenticate with; requires -P option.
-P <password>     SQL Server password to authenticate with; requires -U option.
-E   Authenticate with current Windows credentials.
-C <connection string>
                  Connection string. Instead of specifying a user name,
                  password, and server name, specify a SQL Server connection
                  string. The string must not contain a database name unless
                  otherwise specified.
Finally new database "ASPState" will be created in SQLServer, There will be no tables in this database.States will be stored in temp tables.
TempDB : Tables dbo.ASPStateTempApplications, dbo.ASPStateTempSessions
Connection String :
<sessionStatemode="SQLServer" sqlConnectionString="server=SAURABHPC;trusted_connection=yes"> </sessionState>
NunitNuGet > Install-Package Nunit. [TestClass] [TestMethod]  Assert.AreEqual(expected,actual)
StrongNamesn -k test.snk
Web Garden / Application PoolA single application pool in IIS represents a single w3wp.exe process. Having multiple w3wp.exe process within a single app pool on a single server is called a 'Web Garden' 
Extension MethodsAdd methods to a class without altering the code of that class

Comments

Popular posts from this blog

URL Links