<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.dotnetzone.gr:443/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET WebForms</title><link>https://www.dotnetzone.gr:443/cs/forums/13/ShowForum.aspx</link><description>Θέματα για web εφαρμογές, σε ASP.NET WebForms</description><dc:language>el</dc:language><generator>CommunityServer 2.1 SP3 (Build: 20423.1)</generator><item><title>Re: Coding Model and Compilation in ASP.NET 2.0</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/2462.aspx</link><pubDate>Sat, 04 Jun 2005 09:22:43 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:2462</guid><dc:creator>George J. Capnias</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/2462.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=2462</wfw:commentRss><description>&lt;p&gt;&lt;font style="BACKGROUND-COLOR: #efefef" face="Georgia" size="2"&gt;Κατευθείαν στο ψητό, Αντώνη!&lt;br /&gt;&lt;br /&gt;Πρώτος! &lt;img src="/forums//emoticons/emotion-21.gif" alt="Yes" /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;George J.&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;/p&gt;</description></item><item><title>Coding Model and Compilation in ASP.NET 2.0</title><link>https://www.dotnetzone.gr:443/cs/forums/thread/2431.aspx</link><pubDate>Fri, 03 Jun 2005 18:09:50 GMT</pubDate><guid isPermaLink="false">2622095e-976c-431a-859e-16783ec7ecd7:2431</guid><dc:creator>Antonios Chatzipavlis</dc:creator><slash:comments>0</slash:comments><comments>https://www.dotnetzone.gr:443/cs/forums/thread/2431.aspx</comments><wfw:commentRss>https://www.dotnetzone.gr:443/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=2431</wfw:commentRss><description>&lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="3"&gt;&lt;strong&gt;Coding Model:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;In ASP.NET 1.x you can develop an ASP.NET page in two ways. First, you put code directly inline with your ASP.NET tags. This code inline model is very similar to the ASP coding model and other scripting languages. This model has several problems such as intermixing of code and HTML. ASP.NET 1.0 introduced code-behind as a replacement. It seperated code from content with issues such as inheritance and keep track of two files for each web page.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;ASP.NET 2.0 still supports this two models with some changes...&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;strong&gt;Code Inline:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;The Code inline model is now the default model for Visual Studio 2005.Any code you add to the page will automatically be added to a &amp;lt;script&amp;gt; block within the ASPX file instead of to a code behind class. However, Visual studio 2005 still displays the code in the code view except that code will be placed directly in the ASPX page instead of a separate class.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;strong&gt;Code Behind:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;Difference between a code-behind file in ASP.NET 1.x and ASP.NET2.0 is that a code-behind file is now a partial class rather than a full class that inherits from the ASPX page. A Partial class is a new .NET construct that allows you to define a single class in multiple source files. Partial classes remove the inheritance relationship that is present with the older code behind model.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;Code Behind Models (ASP.NET 1.x and ASP.NET 2.0)&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;img alt="" hspace="0" src="http://www.dotnetheaven.com/Uploadfile/Santhi.M/CodingandCompilationinASPNET206022005080624AM/Images/CodingandCompilation1.gif" align="baseline" border="0" /&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;The two partial classes (ASPX and Code Behind) are merged into a single class during compilation. The code behind file is therefore free of all control declarations and inheritance issues associated with the old code-behind model. Code behind file will no longer contains auto-generated code that used to be necessary to maintain the inheritance relationship.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;Old Code-behind File (ASP.NET 1.x):&lt;/font&gt;&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;class&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; WebForm1 : System.Web.UI.Page&lt;br /&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;protected&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; System.Web.UI.WebControls.Label Label1;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;private&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;font size="2"&gt; Page_Load(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; sender, System.EventArgs e) { }&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;#region&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; Web Form Designer generated code&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;override&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;protected&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; OnInit(EventArgs e)&lt;br /&gt;{&lt;br /&gt;InitializeComponent();&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;base&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt;.OnInit(e);&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;private&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; InitializeComponent()&lt;br /&gt;{ &lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;this&lt;/font&gt;&lt;font size="2"&gt;.Load += &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;font size="2"&gt; System.EventHandler(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;this&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;.Page_Load);&lt;br /&gt;}&lt;br /&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font color="#0000ff" size="2"&gt;#endregion&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;font size="2"&gt; Page_Load(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt; sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;Label1.Text = "Hello World";&lt;br /&gt;}&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;New Code Behind File (ASP.NET 2.0):&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font color="#0000ff" size="2"&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;namespace&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; Sample &lt;br /&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;public&lt;/font&gt;&lt;font size="2"&gt; partial &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;class&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;font size="2"&gt; Webform1_aspx&lt;br /&gt;{&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;void&lt;/font&gt;&lt;font size="2"&gt; Page_Load(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt; sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;Label1.Text = "Hello World";&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;New Code Behind file is cleaner and much easier to read .The code behind files has access to any controls declared on the ASP.NET Page and Visual Studio 2005 provides automatic intellisense support and synchronisation.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="3"&gt;&lt;strong&gt;Compilation:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;In ASP.NET 1.x ,application are compiled on first request or in a batch mode on startup. The disadvantage is we had to deploy uncompiled code into our production server. ASP.NET 2.0 offers new compilation method that precompiles source code into binary assemblies for deployment. Pre-Compiled application consists of assemblies ,resources which of no value for an attacker. PreCompiled application is more secure than an normal ASP.NET application. We will see both version models.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;&lt;strong&gt;Compilation in ASP.NET 1.x&lt;/strong&gt;:&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;The compilation model in ASP.NET is resulted in one application assembly (contains all the compiled code behind files and other source code) and one temporary assembly created for each aspx request. Using batching may cause temporary assembly to be compiled into the same assembly.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;&lt;strong&gt;Disadvantages of this model:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;Uncompiled code to be deployed in production server which is not secure.&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;First time anyone requests the page, response will be slower than normal as ASP.NET runtime has to compile ASPX page.&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;&lt;img alt="" hspace="0" src="http://www.dotnetheaven.com/Uploadfile/Santhi.M/CodingandCompilationinASPNET206022005080624AM/Images/CodingandCompilation2.gif" align="baseline" border="0" /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;br /&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;The only control developer has is whether to compile in batch mode or not. we can configure to run in batch mode in web.config's &amp;lt;compilation&amp;gt; section.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;Benefits of batch compilation is reduced load time for the first time and all the aspx pages will be compiled into single temporary file rather than one temporary file for each page.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;&lt;strong&gt;Compilation in ASP.NET 2.0:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;ASP.NET 2.0 offers three compilaton models.&lt;/font&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;Normal (ASP.NET 1.x model)&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;Code behind files are compiled into assembly and stored in the /bin directory. ASPX files are compiled on demand.&lt;br /&gt;&lt;br /&gt;&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;Deployment Pre-Compilation&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;This is the new feature of ASP.NET 2.0 allows for full compilation of your project prior to deployment. In the full compilation, all code-behind files, aspx pages, HTML, graphic resources and other back-end cide are compiled into one or more executable assemblies. This compilation method provides greatest performance and security but disallows ability to modify the web site post-deployment. This compilation is suitable for highly secure web sites. This will not be suitable for a site which changes frequently.&lt;br /&gt;&lt;br /&gt;&lt;/font&gt; &lt;li&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;Full runtime Compilation&lt;br /&gt;&lt;br /&gt;&lt;/font&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;ASP.NET 2.0 provides a new mechanism to compile the entire application at runtime. You can put your uncompiled code-behind files and any other associated code in the new \app-code directory and let ASP.NET 2.0 create and maintain references to the assembly that will be generated from these files at runtime. This option provides flexibility in terms of changing the web site content .&lt;/font&gt;&lt;/li&gt;&lt;/ul&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt; &lt;p&gt;Choosing the compilation model depends on your exact circumstances and needs, but the compilation model remains flexible.&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" size="2"&gt;Hope you will find this article useful and one more thing Microsoft always makes our life easier. Good Day...&lt;/font&gt;&lt;/p&gt; &lt;p&gt;&lt;font size="2"&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif"&gt;&lt;strong&gt;&lt;font size="3"&gt;References:&lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;br /&gt;&lt;/font&gt;&lt;a target="_blank" title="http://msdn.microsoft.com/asp.net/beta2" href="http://msdn.microsoft.com/asp.net/beta2"&gt;&lt;font face="Verdana, Arial, Helvetica, sans-serif" color="#0000ff"&gt;&lt;u&gt;http://msdn.microsoft.com/asp.net/beta2&lt;/u&gt;&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;</description></item></channel></rss>