Networking Services

29. January 2012

Had to disable WhoIs since port 43 is blocked on the website hosted server. (Queries to WhoIs servers are normally done on Port 43).


Networking Lookups

Whois Server
Domain Name
 
 
 

Your IP: 38.107.179.216
Your Hostname: 38.107.179.216
Remote Address: 38.107.179.216
Server Name: www.itbrigadeinc.com
Server Port: 80
User Agent: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
Language(s): en-us
en;q=0.5

© 2012 IT Brigade Inc.


Note: these Networking Services are  implemented in a C# User Control. The services are done via AJAX updates. Please do not misuse these services.

 


 

By John Dorsey IT Brigade Inc.

ASP.NET, General , , , ,

AJAX not working correctly in BlogEngine.NET 1.6

7. January 2012

Problem

 

I had a lot of issues getting AJAX to work correctly in BlogEngine.NET 1.6.  After updating 3 times, the request URL gets screwed up and a PageRequestManagerServerErrorException was raised with a 404 status code.

Solution

 

I am listing steps I took to get AJAX installed.  Solution to the AJAX issue is at the end of the post.

 

Steps to Installing AJAX

First I only wanted AJAX added for ASP.NET Web User Control (ASCX) files I develop.  So I didn’t add it to the entire website.

Created a simple ASCX to generate random passwords with the link of: http://www.itbrigadeinc.com/post/2012/01/07/Random-Password-Generator.aspx.

Tested this ASCX on my local development server (not in BlogEngine yet). 

Discovered I had to use the AJAX Control Toolkit instead of the AJAX Extensions that included in Visual Studio.  Can download the AJAX Control Toolkit here.

Used the .NET 3.5 version of the Toolkit since that is what I am building BlogEngine with.

Retested on local server and worked fine.

Added ASCX to BlogEngine.NET – this is where I started getting problems

Received the following error on 3rd click of the button:

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 404.

The HTTP request was:

http://localhost:52457/BlogEngine.NET/post/2012/01/07/post.aspx?id=0fb34787-b32d-4c96-a653-aea78ca90ea4

when it should have been:

http://localhost:52457/BlogEngine.NET/post.aspx?id=0fb34787-b32d-4c96-a653-aea78ca90ea4

So it was not requesting the correct page and thereby giving the 404 error.

 

Solution

 

After much research on the internet, I found that someone had a simple solution.

Just add this script block to the end of your ASCX control and it corrects the HTTP request back to:

http://www.itbrigadeinc.com/post/2012/01/07/Random-Password-Generator.aspx

 

Solution
  1. <script type="text/javascript">
  2.     Sys.Application.add_load(function () {
  3.         var form = Sys.WebForms.PageRequestManager.getInstance()._form;
  4.         form._initialAction = form.action = window.location.href;
  5.     });
  6.  </script>

 

 

John Dorsey
IT Brigade Inc.
www.itbrigadeinc.com

ASP.NET, BlogEngine.NET ,

Random Password Generator

7. January 2012

Use this password generator to generate Strong, Secure, Random passwords with the characteristics you desire!   Cell phone/mobile device option to create easier passwords for smaller keypads.

This Random Password Generator generates a password using the following requirements:

Password is from 8-12 characters in length.  You can choose the Length or allow a random Length.

There are 3 categories of characters which are randomly included in the password:

    Letters: 26 character English Alphabet with Upper and Lower Case values.

    Numbers: 0 to 9

    Symbols: ()[]<>,.?;:!+-=*/^$&%You can choose the Symbols you want to include.

At least 1 character from each category must be included in the password. The first character is always an alpha.

A cell phone-friendly password mode is provided (for cell phones/mobile devices with numeric/symbolic keys are on a separate keypad from the alpha keys).  Also restricted to lower case characters since it is trickier to go between cases on a cell phone/mobile devices.    Cell phone-friendly password: 8 alpha characters which are all lower case.

The password is created using a  random number generator, so each password is always unique.

 

The Random Password Generator is provided as a Free Service by IT Brigade Inc.


Random Password Generator

Number of Characters
Special Characters to Include

 



Y,.0A+0B

© 2012 IT Brigade Inc.

 

ERROR - UNABLE TO LOAD CONTROL : ~/User controls/RandomPasswordGenerator1.ascx


Note: the Random Password Generator is implemented as a C# User Control. Regeneration of passwords is done via AJAX updates. Generated passwords are not saved by this website.



John Dorsey
IT Brigade Inc.
www.itbrigadeinc.com

ASP.NET , , , , ,

How to add another page to your BlogEngine.NET 1.6 Website

5. November 2011

Summary

This article describes how to add another page to your BlogEngine.NET 1.6 web blog.  The page will also be added to the main menu on your blog and can be edited with Windows Live Writer. (I use Windows Live Writer to create/edit my blogs).  See my article on Windows Live Writer.

Description

Pages are very confusing in BlogEngine.NET 1.6.  They don’t seem to be linked to anything and are not shown on the menu. 

I wanted to add an “About” page similar to the “Contact” page for my BlogEngine.NET 1.6 website.  I tried to add a page using the website Administrator functions, but that added a page that was not linked into the posts or main page.  It was lost somewhere in the blog…

Solution

Finally figured out the EASY way to do it:

1. Use the BlogEngine.NET administrator function in your website to add a new page, in my case the “About” page.  Don’t set a parent for that page.  Set the Slug to the page name – in this case: “About”.

2. Go to the site.master page in the theme you have selected and find the menu items.  Add a new menu item with the following format:

<li <%=MenuClass("About.aspx")%>><a href="<%=Utils.AbsoluteWebRoot %>page/About.aspx">About</a></li>

Note: the addition of the “page/” to link up the menu with the page created in step 1.

3. Build and deploy your website.

4. Open Windows Live Writer and “Open Recent Post”.  Select your blog and select “Pages” (not “Posts”).  Select the “About” page you created.

5. Edit your “About” page and Publish.

 

That's All!

 

John Dorsey
IT Brigade Inc.
www.itbrigadeinc.com

BlogEngine.NET, ASP.NET ,

Publishing a Visual Studio Website

3. November 2011

This is applicable to Microsoft Visual Studio.NET developed Websites.  I found this to be true on both VS 2008  (.NET 3.5 Framework) and 2010 (.NET 4.0 Framework).

 

I honestly don’t know why this fact doesn’t get more airtime:

When publishing a website in Visual Studio USE the following setting:

accept “Use fixed naming and single page assemblies”

Do NOT use:

cross “Allow this precompiled site to be updatable”

This appears to opposite of the default settings in Microsoft Visual Studio.

This is particularly important for websites with low traffic.

 

When you do this, the website will respond much faster!

 

Explanation:  The settings have to do with the pre-compilation of the assemblies used by the website.  The settings are VERY, VERY CONFUSING!

  • “Use fixed naming and single page assemblies” means that the entire site is compiled.  This is FAST!
  • “Allow the precompiled site to be updatable” means that the site will be dynamically compiled when it has been inactive for a set amount of time.  The end result is that the website is VERY SLOW to respond when it is hit.

ASP.NET , ,

Dumping Binary File to a Hex File

6. June 2011

If you are trying to determine values in a binary file, it is virtually impossible to read.  Here’s a quick C#.NET function to read in a binary file and dump it out in hex representation.

 

Remember to add:

using System.IO;

Binary File Hex Dump (C#.NET)
  1. private void DumpHex(string binaryFile, string hexDumpFile)
  2. {
  3.     // write out address followed by 16 bytes of data (example lines shown):
  4.     // 0000: ff d8 ff e1 02 62 45 78 69 66 00 00 4d 4d 00 2a
  5.     // 0010: 00 00 00 08 00 08 01 0f 00 02 00 00 00 04 48 54
  6.     // 0020: 43 00 01 10 00 02 00 00 00 0a 00 00 00 6e 01 1a
  7.  
  8.     int address = 0;
  9.     int newLineCounter = 0;
  10.     bool finished = false;
  11.     int readByte = 0;
  12.     using (StreamWriter writer = new StreamWriter(hexDumpFile))
  13.     {
  14.         using (FileStream reader = File.OpenRead(binaryFile))
  15.         {
  16.             while (!finished)
  17.             {
  18.                 if ((readByte = reader.ReadByte()) < 0)
  19.                 {
  20.                     finished = true;
  21.                 }
  22.                 // write out address (hex format)
  23.                 if (newLineCounter == 0 && !finished)
  24.                 {
  25.                     writer.Write(String.Format("{0:x4}: ", address));
  26.                 }
  27.                 if (!finished)
  28.                 {
  29.                     // write out byte value
  30.                     writer.Write(String.Format("{0:x2} ", readByte));
  31.                     newLineCounter++;
  32.                 }
  33.                 if (newLineCounter == 16 || finished)
  34.                 {
  35.                     // write out new line
  36.                     writer.Write(Environment.NewLine);
  37.                     address += 16;
  38.                     newLineCounter = 0;
  39.                 }
  40.             }
  41.         }
  42.     }
  43. }

Disclaimer: This is not production quality software.  There are no exception handlers added.  There was no attempt to optimize the code.  Testing was extremely limited. 

 

The sample data shown in from a jpg image.  That’s why it starts out as 0xffd8ffe1.

John Dorsey

IT Brigade Inc.

www.itbrigadeinc.com

ASP.NET ,

Welcome to the confusing world of Microsoft Interop Assemblies

5. April 2011

Once again had problems updating an older project to Visual Studio 2010.  And the culprit: Microsoft Interop Assemblies.  I can't count the number of times this has happened over the years.

Received the following error when building the project: Cannot find wrapper assembly for type library "Microsoft.Office.Core".

Solution:

  1. Change Application Target Framework from .NET Framework 2 to .NET Framework 4.
  2. Download Microsoft Office 2010: Primary Interop Assemblies
  3. Remove Microsoft.Office.Core reference
  4. Add reference to Office, got conflict, so removed the reference
  5. Microsoft.Office.Interop.Excel now updated to Microsoft Excel 14.0 Object Library (not sure what went on there...)
  6. Project now builds and the Excel spreadsheet built by the program works.

Like I said: Confusing!

Explanation on Microsoft Primary Interop Assemblies (PIA):

These assemblies are used to interact with an Office application from a .NET program.  For example, if you want to create an Excel spreadsheet from your program directly, you can create a spreadsheet, perform operations on it, and save it within your program.  The downside is that these assemblies interact with the Office applications via COM interface so they are very slow in general.

John Dorsey
IT Brigade Inc.
www.itbrigadeinc.com

 

ASP.NET , , ,

Getting your old Access programs working on Windows 7

17. February 2011

When I tried to run an old .NET program which uses Access I got the following error on Windows 7:

The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine

Looked on the web and found the following article: Windows 2008 / Windows 7 x64: The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine

2 Steps to fix for my Windows 7 64-bit machine:

1. Download 2007 Office Driver System from Microsoft.

2. Rebuild program with platform target set to x86.

 

ASP.NET, Access ,

Learning C# by Example

16. February 2011

 

An excellent resource for C#: http://www.fincher.org/tips/Languages/csharp.shtml

Shows code samples for all those hard to remember aspects of C# :

Reading/Writing to files

Working with XML

Formatting output strings

Inheritance

Overloading operators

Working with Webpages

Database access

...

ASP.NET , ,

Tips & Tricks for Visual Studio 2008

3. May 2010