Sunday, 31 August 2014

What is ASP.Net and its difference with classic ASP

What is ASP.Net
 ASP.Net is a server side scripting technology. It is a developent framework for building web pages and web sites with HTML, CSS , JavaScript and server side scripting. Server side scripting means code can be executed by the server , not in the client browser. So that we can use compiled code that can be run at the server. Hence ASP.Net provides increased performance by running compiled code.

There are many differences between the classic ASP and ASP.Net.

Difference between ASP.Net and ASP

ASP.Net

1. ASP.Net webforms can have code behind file for event handling code. That is seperate code and design logic is possible ( .aspx and .cs )
 2. ASP.Net webforms inherit the class written in code behind.
 3. ASP.Net web applications are configurable. That is web.config file can be used for configuring the application.
 4. ASP.Net is object oriented. That is OOPS concepts are implemented in asp.net.
 5. Complete session and application state management.
 6. ASP.Net webforms have ADO.Net and full XML support for easy data exchange.
 7. Variety of compilers and tools are available.
 8. Custom controls can be used with the help of @Register directive.
 9. Many languages can be used for programming ( C#, VB.Net, J# etc ).

ASP

1. In ASP, code and design cannot be in separate files. That is it have mixed HTML and code logic.
 2. Only a limited OOPS support. For example, Inheritance is not available.
 3. ASP uses scripting languages like Jscript or Vbscript.
 4. Only a limited development and debugging tools are available.
 5. Custom controls cannot be possible with ASP.
 6. Limited session and state management.

Thursday, 4 August 2011

How to send mails automatically after a time period????


We need something in ASP.NET that is continuously running and gives us a callback. The IIS web server is continuously running. So, we somehow need to get a frequent callback from it so that we can lookup a job queue and see if there's something that needs to be executed. Now, there are several ways a web server comes to us:
  • When a page hits
  • When an application starts
  • When an application stops
  • When a session starts and ends/timeouts
  • When a cache item expires
The page hit is random. If nobody visits your website for hours, you can't do the pending jobs for hours. Besides, the execution of a request is very short and needs to finish as soon as possible. If you plan to execute scheduled jobs on page execution, then the page will take longer to execute, which will result in a poor user experience. So, clearly this is not an option.
When an application starts, we get a callback in the Application_Start method of Global.asax. So, this is a good place to start a background thread which runs forever and executes scheduled jobs. However, the thread can be killed anytime the web server decides to take a nap due to zero load.
When an application stops, we get a callback at Application_End. But we can't do anything here because the whole application is going to die soon.
Session_Start in Global.asax is triggered when a user visits a page that requires a new session to be initiated. So, this is also random. We need something that fires consistently and periodically.


A cache item expires on a given time or duration. In ASP.NET, you can add entries in the Cache and set an absolute expiry date time, or you can set a duration after which the item is removed from the cache. You can do this by utilizing the following method of the Cache class:
public void Insert ( System.String key , System.Object value , 
                     System.Web.Caching.CacheDependency dependencies , 
                     System.DateTime absoluteExpiration , 
                     System.TimeSpan slidingExpiration , 
                     System.Web.Caching.CacheItemPriority priority , 
                     System.Web.Caching.CacheItemRemovedCallback onRemoveCallback )
The onRemoveCallback is a delegate to a method which is called whenever a cache item expires. In that method, we can do anything we like. So, this is a good candidate for running code periodically, consistently without requiring any page visit.



Thank You...