Archive for the ‘.NET’ Category

today i came across this issue once i enabled ‘Enable 32-bit Applications‘ to true on IIS

full error is

“The Module DLL ‘C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\isapi\spnativerequestmodule.dll’ could not be loaded due to a configuration problem. The current configuration only supports loading images built for a x86 processor architecture. The data field contains the error number. To learn more about this issue, including how to troubleshooting this kind of processor architecture mismatch error”

and then you browse the page it give’s HTTP Error 503. The service is unavailable since the app pool is stopped due to that error

Reason for the error
this because SharePoint’s  “spnativerequestmodule.dll ” only supports the 64 bit and when it tried to load on 32 bit environment it crashes


run this command on command prompt

“%systemroot%\system32\inetsrv\AppCmd.exe” set config section:system.webServer/globalModules /[name=‘SPNativeRequestModule’].preCondition:integratedMode,bitness64″

This will direct the SPNativeRequestModule to only be loaded when the application pool is running in Integrated Mode and 64-bit application mode.


ASP.NET Web Forms versus MVC

Posted: Sunday, June 30, 2013 in .NET,

I found this blog post which talks about ASP.NET Web Forms versus MVC

Gridview Linkbutton Postback Problem

Posted: Monday, April 8, 2013 in .NET,

Some of the Devs in my team had a problem with linkbuttons inside a Gridview template field.

When they clicked on the linkbutton it didn’t postback.

I thought it’s an application wide issue, but in some pages it worked.

Then it came into my mind the issue is coz of the validation controls in some of the page.

When use clicks on a gridview’s  linkbutton, if the page have validation controls, it will fire them,

BUT IT WON’T SHOW THE VALIDATION MESSAGE to the end user. So the user thinks it’s an another issue.

To fix this you can add CausesValidation=”false” attribute to the linkbutton.

Reset Identity Column without Truncating the Table

Posted: Tuesday, March 6, 2012 in .NET

Quick tip
if you want to reset identity column without truncating the table (to truncate the table you need to remove foreign constrains) run
DBCC CHECKIDENT (tablename, reseed, 0)

Lets say you need to add itemtemplate dynamically to your gridview and also wants to data bind the sub class which loads with your main class.

Ex:- Person.Car.Type
If you bind list of person as the data source, in the data binding event of the control you can simply call
DataBinder.Eval(container.DataItem, “myCar.type”);

This is a sample code you can use .

protected void Page_Load(object sender, EventArgs e)
List<person> pl = new List<person>();
for (int i = 0; i < 5; i++)
person p = new person();
p.age = i.ToString(); = “name” + i.ToString();
p.myCar = new car();
p.myCar.type = “Nissan” + i.ToString();

TemplateField tmp = new TemplateField();
tmp.ItemTemplate = new TemplateData();

GridView1.DataSource = pl;

class person
public string name { get; set; }
public string  age { get; set; }
public car myCar { get; set; }

class car
public string name { get; set; }
public string type { get; set; }

public class TemplateData : ITemplate
void ITemplate.InstantiateIn(Control container)
Label lb = new Label();
lb.ID = “lb”;
lb.DataBinding += new EventHandler(lb_DataBinding);

void lb_DataBinding(object sender, EventArgs e) {
Label lb = (Label)sender;
GridViewRow container = (GridViewRow)lb.NamingContainer;
object dataValue = DataBinder.Eval(container.DataItem, “myCar.type”);
lb.Text = dataValue.ToString();

In my web project for all the pagers I was inheriting from base page. Then I realize that in VS it gives and error in HTML design mode saying  “Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive.”

The issue was that I was using session object in the OnInit method in my base then I move my code to OnLoad mothod and then in VS the rendering error disappeared.

BTW in first scenario also when I run the code it worked well.


Posted: Tuesday, December 6, 2011 in .NET, Microsoft

I’m sure that most of the devs out there have faced this issue. Have you ever wanted to test SMTP mail sending logic on dev machine and wanted to use a SMTP server?
smtp4dev will give you a dummy SMTP server in order to test your mail sending logic. This will listen on port 25 on your dev machine. This is really nice utility to have.

You can download this on codeplex :-