Enable/Disable multi-core JIT compilation in ASP.NET vNext

by abhilashca 1. October 2011 18:35

 

One of the feature implemented as part of performance improvement in ASP.NET vNext is – multi-core JIT compilation. This give a better performance boost specially after a  cold site boot (e.g.. AppPool recycle, etc). This functionality is implemented in System.Runtime.ProfileOptimization.StartProfile method.

Thankfully, this feature is enabled by default. You don’t have to make your hands dirty to enable it. And, if you want to turn-off this feature, then do include the below code in your website’s web.config file.

   1: <system.web> 
   2:     <compilation profileGuidedOptimizations="None"  />
   3: </system.web>

Thanks.

ASP.NET vNext

by abhilashca 1. October 2011 17:55


Did you hear that? ASP.NET vNext is around the corner!

Check out here to know what’s new in ASP.NET vNext. I’m so impressed with the new set of features tied with the ASP.NET framework.

Get Ready! Sharpen your tools!

 

Categories: ASP.NET

Control must be placed inside a form tag with runat=server

by abhilashca 11. August 2011 20:14


Oops…!!!

Last night, when i tried to call GridView.RenderControl(), I’s kicked with a runtime exception as below:

gridview_rendererror6

What surprised me more, that my GridView is inside the <form> tag, with runat=server attribute. I binged for a while and came to know that I’m not alone for this error. On deep searching, I find that Microsoft Connect has confirmed this as a bug. Which further take me to two other MSDN links:- Link1, Link2.

In the end, I got the fix.

All you’ve to do is to include the below empty-code in the code-behind

// [Code-Behind]
public override void VerifyRenderingInServerForm(Control control)
    {
        //Empty Method
    }
 


Thanks!

Remove Empty Records from DataTable

by abhilashca 7. August 2011 16:23


Recently, I have to upload an Excel file contents to a Database. As usual, I wrote the code for retrieving Excel sheet values into a DataTable using the OleDb connection. Oops! the uploading crashed when I realized that the contents read has empty records in it. I tried for some standard techniques for removing empty records. Since, the column names of Excel sheet may varies (in my case), I have to give up the standard way and have to stick with the old lame mechanism of iterating through all the records searching for empty rows. Crying face

And here is the code sample:

   1: bool isEmpty = true;
   2:  
   3: DataTable dt = new DataTable("Table1");
   4: dt.Columns.Add("Id", Type.GetType("System.Int32"));
   5: dt.Columns.Add("Name", Type.GetType("System.String"));
   6:  
   7: dt.Rows.Add(1, "Name1");
   8: dt.Rows.Add(2, "Name2");
   9: dt.Rows.Add(3, "Name3");
  10: dt.Rows.Add(null, null);
  11: dt.Rows.Add(null, null);
  12: dt.Rows.Add(6, "Name4");
  13: dt.Rows.Add(null, null);
  14: dt.Rows.Add(8, "Name5");
  15: dt.Rows.Add(null, null);
  16: dt.Rows.Add(null, null);
  17: dt.Rows.Add(null, null);
  18:  
  19: for (int i = 0; i < dt.Rows.Count; i++)
  20: {
  21:     isEmpty = true;
  22:  
  23:     for (int j = 0; j < dt.Columns.Count; j++)
  24:     {
  25:         if (string.IsNullOrEmpty(dt.Rows[i][j].ToString()) == false)
  26:         {
  27:             isEmpty = false;
  28:             break;
  29:         }
  30:     }
  31:  
  32:     if (isEmpty == true)
  33:     {
  34:         dt.Rows.RemoveAt(i);
  35:         i--;
  36:     }
  37: }

Please note, this code is just a simulation. There might be better code out there Winking smile

Thanks.