Friday, October 26, 2012

How to speed up ASP.net page load after compilations.



First thing I did to reduce the compile time is to set my "batch" flag to false 
As per MSDN

the batch flag "eliminates the delay caused by the compilation required when you access a file for the first time. When this attribute is set to True, ASP.NET precompiles all the uncompiled files in a batch mode, which causes an even longer delay the first time the files are compiled. However, after this initial delay, the compilation delay is eliminated on subsequent access of the file."


Secondly I set "optmizeCompilation" flag to true, which was introduced with .net 3.5_sp1. By setting this flags I reduced my ASP.net load time after compilation from 2 minutes to 7 seconds on average.

for further info please read below MSDN link special advantage/disadvnatage of Dynamic compilation part. 

http://msdn.microsoft.com/en-us/library/ms366723%28v=vs.100%29.aspxhttp://msdn.microsoft.com/en-us/library/ms366723%28v=vs.100%29.aspx

Below is what my looks like in Web.config file.

<compilation defaultLanguage="C#" debug="true" batch="false" optimizeCompilations="true" />

Javascript Framworks

http://jster.net/category/mobile-frameworks#.UImwrdeDYnK

ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer

 

http://support.microsoft.com/kb/312629

the reason this happens, is because

The Response.End method ends the page execution and shifts the execution to the Application_EndRequest event in the application's event pipeline. The line of code that follows Response.End is not executed.
This problem occurs in the Response.Redirect and Server.Transfer methods because both methods call Response.End internally.

 

To work around this problem, use one of the following methods:

  • For Response.End, call the HttpContext.Current.ApplicationInstance.CompleteRequest method instead of Response.End to bypass the code execution to the Application_EndRequest event.
  • For Response.Redirect, use an overload, Response.Redirect(String url, bool endResponse) that passes false for the endResponse parameter to suppress the internal call to Response.End. For example:

      Response.Redirect ("nextpage.aspx", false);
    						

    If you use this workaround, the code that follows Response.Redirect is executed.

  • For Server.Transfer, use the Server.Execute method instead.

Tuesday, March 22, 2011

Use USB to Cleanup Malware infected PCs

Use Malwarebytes Anti-Malwareand SUPERAntiSpyware to get rid or Malware. Use SUPERAntiSpyware Portable Scanner to put it on USB.

I write-protect the flash drive using a free tool called USB Write Protect, which will prevent the drive from becoming infected

Thursday, December 09, 2010

JavaScript self-executing anonymous function

In JavaScript you can write anonymous function as follow…

  
   (function(){
       var foo = 'Hello World';
   })();

   alert(foo);  //will get Error undefine foo

now you may argue that, why would I ever want to use self-executing function this way? Where I could always do...

 
   var foo = 'Hello World';
   alert(foo);

Yes definitely you can do that but this way you will create foo object that is a global object and you may never ever use it again…

In conclusion self-executing anonymous function is useful for time where
you want to avoid polluting the global namespace with your code.

Wednesday, February 03, 2010

HtmlLink control to programmatically add a Stylesheet to a Web Page

Source Where I found following code

  protected void Page_Init(object sender, EventArgs e)
  {
    // Define an HtmlLink control.
    HtmlLink myHtmlLink = new HtmlLink();
    myHtmlLink.Href = "~/StyleSheet.css";
    myHtmlLink.Attributes.Add("rel", "stylesheet");
    myHtmlLink.Attributes.Add("type", "text/css");
    
    // Add the HtmlLink to the Head section of the page.
    Page.Header.Controls.Add(myHtmlLink);
    
  }

Friday, May 29, 2009

ASP.NET error CS1026: ) expected

Today I came across this error, so I did Google search on it I came across below blog
http://www.romsteady.net/blog/2007/07/caspnet-error-cs1026-expected.html

the reason for error was semicolon inside the server tag.
var mShowRawData = '<%= common.ShowRawData; %>'

instead just write
var mShowRawData = '<%= common.ShowRawData %>'

Sunday, March 22, 2009

IE8 JavaScript Debugger statement not working

Well I just downloaded Internet Explorer 8, after playing with it for a while, I started programming using. I have Visual Studio 2005 installed on my box, and suddenly I notice that IE8 is not responding to my “Debugger” statements in the JavaScript. After numerous Google queries i decided to take matters into my own hands. I started playing with built in debugger’s option, within few seconds what I saw “Script” tab inside I saw “Start Debugging” button. So all I had to do was to click on Start Debugger and suddenly it started hitting all the “debugger” statements.

image

Tuesday, March 17, 2009

On Postback or Submit button new window opens

Several days ago, I came across issue, when I click on button inside a dialogbox’s it opens up a new window. So I asked one of the co-worker see if he has seen this behavior, and he goes like just add below code inside head tag. 
<base target=_self>

Note: this will not work with IE5