Tag Archives: visualstudio

Don’t do iisreset do …

a mini batch file in your start menu, when you’re debugging the application startup of a .Net application, and keep wanting to restart it:

taskkill /im aspnet_wp.exe /f
if not errorlevel == 0 pause

or

taskkill /im w3wp.exe /f
if not errorlevel == 0 pause

which does the job much faster.

Assuming, of course, that your reason for wanting to do an iis reset was to force a .Net application restart. And you don’t mind forcing all running .Net applications to restart. And you’re not on a busy production machine at rushhour.

Localising programmatically in asp.net code behind

The usual examples for asp.net localisation are for the aspx markup page, not for the code behind.

In fact localisation, accessing localisation resource files programmatically, in code behind is also dead simple. You use GetLocalResourceObject() like so:

ctrl.Text = (string)GetLocalResourceObject("myCtrlKey.Text");
ctrl.AnotherAttribute = (string)GetLocalResourceObject("myCtrlKey.AnotherAttribute");

Using LocalResource means that for a page called MyPage.aspx, you have created a resource file called MyPage.aspx.resx and/or MyPage.aspx.{culturename}.resx in the special directory App_LocalResource.

If you like GlobalResources instead of local, use the special directory App_GlobalResource
to hold a resource file called MyResourceFileName.resx and call:

ctrl.Text= (string)GetGlobalResourceObject("MyResourceFileName", "myGlobalKey");

as per http://msdn.microsoft.com/en-us/library/ms227982.aspx

For a bit more of an overview of asp.net localisation, the page at http://msdn.microsoft.com/en-us/library/ms227427.aspx should only take you a few minutes to scan.