Archive for the ‘Tips’ Category

Read Authorization section from Web.config

In my current project, I had to read the find the Windows group for the ESB portal which can be found in the authorization section of the web.config for the ESB portal. I used the following code to read it:

var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(“/Bam”, “Default web Site”);
var section = config.GetSection(“system.web/authorization”) as AuthorizationSection;

if (section == null)
    return string.Empty;

foreach (AuthorizationRule rule in section.Rules)
     if (rule.Action.ToString().ToLower() == “allow” && rule.Roles.Count > 0)
        foreach (var item in rule.Roles)
            if (item != “*”)
                return rule.Roles[0];
return string.Empty;


Categories: .NET,, C#, Tips Tags: , ,

Biztalk: Instance was not successfully terminated. Status is Pending

Sometimes when you try to terminate messages in Biztalk, messages may fail to terminate. Before you force the termination, you need to make sure you are ONLY terminating the messages you intend to terminate.

To force the termination, try one of the following:

Restart/Stop host instances assigned to the port or orchestration

Recycle the application pool assigned to the Webservice/WCF service if the port’s host is an isolated host

You can also wait for Biztalk to finish retrying sending the message, hence messages become suspended instances

IIS: There was an error while performing this operation

This is more of a tip than a post. Today I had  the following error in IIS while modifying Handler Mappings

There was an error while performing this operation.


Filename: \\?\C:\SomePath\web.config

Error: Cannot write configuration file due to insufficient permissions


We are using TFS, and TFS sets the Readonly flag when the file is checkin. Basically, all you need is to check out the web.config before do your modifications in IIS

Categories: Tips Tags: ,

LightSwitch: Hide Export to Excel Button

To hide the Export to Excel button follow these steps:

Open the screen

In the screen designer, select the Data Grid whose excel button to be hidden

Open property window or press F4

Check Disable Export to Excel


Launch the application

Categories: LightSwitch, Tips Tags: ,

Lightswitch: Hide Grid’s Search Textbox

In some cases, we need to hide the search textbox on top of the grid.


To hide the textbox following these steps:

Open the screen that contains the grid

Select the query for the grid whose search textbox need to be hidden

Open Property Window (or hit F4)

Uncheck Support Search

Run the application

Categories: LightSwitch, Tips Tags: ,