Is IronRuby Dead?

Pro-tip: developers hate making announcements. We’re antisocial creatures. IronRuby was last committed to 5 days ago (as of the time of this post). So it’s very much alive. https://github.com/IronLanguages/main/tree/master/Languages/Ruby

How to use the ConfigurationManager.AppSettings

Your web.config file should have this structure: <configuration> <connectionStrings> <add name=”MyConnectionString” connectionString=”…” /> </connectionStrings> </configuration> Then, to create a SQL connection using the connection string named MyConnectionString: SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings[“MyConnectionString”].ConnectionString); If you’d prefer to keep your connection strings in the AppSettings section of your configuration file, it would look like this: <configuration> <appSettings> … Read more

Mocking User.Identity in ASP.NET MVC

I’ve used IoC to abstract this away with some success. I first defined a class to represent the currently logged in user: public class CurrentUser { public CurrentUser(IIdentity identity) { IsAuthenticated = identity.IsAuthenticated; DisplayName = identity.Name; var formsIdentity = identity as FormsIdentity; if (formsIdentity != null) { UserID = int.Parse(formsIdentity.Ticket.UserData); } } public string DisplayName … Read more

Caught exception is null itself !

For anyone ending up here, I’ve found an instance where this is possible (If only detectable in the debugger). VS2013 Update 4. Broken: try { // do something } catch (WebException ex) // <- both variables are named ‘ex’ { Logger.Log(“Error while tried to do something. Error: ” + ex.Message); } catch (Exception ex) // … Read more

ContentResult vs. string

If you return something other than an ActionResult the default behavior is to create a ContentResult wrapping the result of calling ToString() on whatever you did return (or EmptyResult if you returned null). Reasons I can think of to explicitly return ContentResult: It reinforces the fact that the method is an action, rather than a … Read more

Difference between AutoPostBack=True and AutoPostBack=False?

Taken from http://www.dotnetspider.com/resources/189-AutoPostBack-What-How-works.aspx: Autopostback is the mechanism by which the page will be posted back to the server automatically based on some events in the web controls. In some of the web controls, the property called auto post back, if set to true, will send the request to the server when an event happens in … Read more

SelectedValue vs SelectedItem.Value of DropDownList

SelectedValue returns the same value as SelectedItem.Value. SelectedItem.Value and SelectedItem.Text might have different values and the performance is not a factor here, only the meanings of these properties matters. <asp:DropDownList runat=”server” ID=”ddlUserTypes”> <asp:ListItem Text=”Admins” Value=”1″ Selected=”true” /> <asp:ListItem Text=”Users” Value=”2″/> </asp:DropDownList> Here, ddlUserTypes.SelectedItem.Value == ddlUserTypes.SelectedValue and both would return the value “1”. ddlUserTypes.SelectedItem.Text would return … Read more

Window application flash like orange on taskbar when minimize

I do it as shown below, being sure to add the required references as shown using System.Runtime.InteropServices; using Microsoft.Win32; // To support flashing. [DllImport(“user32.dll”)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool FlashWindowEx(ref FLASHWINFO pwfi); //Flash both the window caption and taskbar button. //This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags. public const UInt32 FLASHW_ALL = … Read more