Quick way to debug/display MVC or WebForms session data on live server without deploying

This works for both MVC and web forms.

Create a text file called for example “test.aspx”. Edit to have content shown below. Copy the file to root folder of your web site then browse : http://yoursite.com/test.aspx


   
<%@ Language=C# %>
<html>
   <script runat="server" language="C#">
   void MyButton_OnClick(Object sender, EventArgs e)
   {
      lblSessionId.Text = "Session ID : " + Session.SessionID + " @ " + DateTime.Now.ToLongTimeString();
 	lblThreadCultureName.Text = "Thread culture name : " + System.Threading.Thread.CurrentThread.CurrentCulture.DisplayName;
 	lblThreadUICultureName.Text = "Thread UI culture name : " + System.Threading.Thread.CurrentThread.CurrentUICulture.DisplayName;
   }
   </script>
   <body>
      <form id="MyForm" runat="server">
         <asp:button id="MyButton" text="Click here to display session ID" OnClick="MyButton_OnClick" runat="server"></asp:button>
         <asp:label id="lblSessionId" runat="server"></asp:label><br/>
          <asp:label id="lblThreadCultureName" runat="server"></asp:label><br/>
         <asp:label id="lblThreadUICultureName" runat="server"></asp:label><br/>

      </form>
   </body>
</html>  

C# Example of getting the index of items in a LINQ Select query

    class Program
    {
        private static List<Book> _books  = new List<Book>
        {
            new Book {Id = 9999, Title = "Book A" },
            new Book {Id = 22, Title = "Book B" },
            new Book {Id = 3876, Title = "Book C" },
        };

        static void Main(string[] args)
        {
            // In the LINQ lambda the second parameter is the index 
            var bookList = Books.Select((b, i) => new { Index = i, Book = b }).ToList();

            foreach (var bookWithIndex in bookList)
            {
                Console.WriteLine(string.Format("Book Id: {0}, Title : {1}, Index: {2}", 
                    bookWithIndex.Book.Id, 
                    bookWithIndex.Book.Title, 
                    bookWithIndex.Index));
            }

            Console.ReadKey();
        }

        static IEnumerable<Book> Books
        {
            get
            {
                foreach (var book in _books)
                {
                    yield return book;
                }
            }
        }
    }

    public class Book
    { 
        public int Id { get; set; }
        public string Title { get; set; }
    }

Installing Umbraco – login failed for user admin

On creating a new Umbraco site the wizard prompts you to create an administrator account.  It prompts for:

  • Name                       – you enter [admin]
  • Email                        – you enter [john@test.com]
  • Password                 – you enter [testing123]

Then click “install”

The site loads.  Append “/umbraco” to the site’s url and you can enter the backend.

You logout.

You try to login with the following details:

Username: admin

Password: testing123

You get an error – login failed for user admin.    WTF???

Ok try this:

Username: john@test.com

Password: testing123

You’re in!

To be fair when entering the administrator username and password it does say underneath that “Your email will be used as your login”.  But still shite in my opinion.

Octopus Deploy – promoting releases with different configuration

Using Octopus Deploy v3.x it is possible to promote a release to different environments using different configuration for each environment.

For example on DEV it is possible to use the web.dev.config transform and a IIS host header of mysite.dev. On QA the web.qa.config transform would be used and the IIS host header would be mysite.qa.

Create a step to deploy the web site to IIS and enable it for DEV and QA environments:

Octopus1

Create environment specific variables for web.config transform and host header:

Octopus2

To transform web.dev.config and web.qa.config to web.config depending on the environment then edit the “Additional Transforms” in the “Configuration Transforms” section like this:

Octopus3

To use the host header variable edit the “IIS Bindings” section like this:

Octopus4

Windows 10 development machine with Oracle VirtualBox

I’m using Oracle VirtualBox version 5.0.1.r101957 installed on Windows 10 Enterprise (64 bit).

Install VirtualBox.

Create a new Windows 10 PC – I created with fixed size hard drive with size 260GB.

Power on & install Windows 10 64 bit.

Install Guest Additions:

  • to do this power on the Win10 virtual box
  • from the virtual box menu select Devices -> Insert Guest Additions ISO
  • Then from the mounted ISO run VBoxWindowsAdditions.exe
  • Reboot

Install Visual Studio 2015

Install SQL server dev edition

Enabling dual screens on VirtualBox machine:

  • Power down the virtualbox machine
  • From the VirtualBox manager select the machine
  • then click Settings
  • Click Display
  • Change Monitor Count to 2

Then…

  • Start virtualbox machine
  • From the VirtualBox menu select View -> Virtual Screen 2 -> enabled

Installing Couchbase Community Edition on Windows 10

Navigate to couchbase.com and click Download

Scroll down to the Couchbase Server section. Click the version link until you get option to select Community Edition:
couchbase1

Select Community Edition then click Download:
couchbase2

I then ran the setup and accepted all defaults. At the end of the setup process the couchbase server is started and browser window opens where you continue to setup. Accept all defaults and I chose to install the “beer-sample”.

To view the couchbase dashboard navigate to http://localhost:8091/index.html