Use of App_Code Folder

In older .net versions, App_Code Folder help to reorganize and make the code simple for the programmer.
App_Code Folder is a default folder that is provided with the applications. The files inside it are compiled automatially whenever you change anything within them. All classes in this folder are referenced automatically in the rest of the application.

1) One of the major advantage of App_Code Folder is, if you put class files inside that , then you don't need to compile .
This means, whatever files inside it are all PRE-COMPILED.

2) Second advantage is, sometimes we have to give right-permission previlages if we create our own folder. But in App_code folder, you don't need it.


Author: PalaniKumar.A15 Jul 2011 Member Level: Gold   Points : 1


It is very nice definition.

Sample Program:


Imports System.Data

Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Dim cl As ClassName = New ClassName()
End Sub
End Class

App_Code Folder Class Name:classname.vb

Imports Microsoft.VisualBasic

Public Class ClassName
Public Sub Class1()

End Sub
Public Sub toExcel(ByVal GridView1 As GridView)
Dim httpContext As System.Web.HttpContext = httpContext.Current

httpContext.Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
httpContext.Response.Charset = ""
httpContext.Response.ContentType = "application/vnd.xls"

Dim sw As System.IO.StringWriter = New System.IO.StringWriter
Dim hw As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(sw)

End Sub

End Class

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: