Great blog article detailing how to host and manage multiple domains under a single hosting plan.
http://weblogs.asp.net/owscott/iis-url-rewrite-hosting-multiple-domains-under-one-site
Technical blog discussing various programming languages, frameworks and paradigms. Code snippets and projects are also provided.
Tuesday, 25 November 2014
Monday, 24 November 2014
iPhone/iPad - How to Sniff iOS Traffic Using Fiddler on Windows
Here is a great article on how to sniff all traffic on an iOS device! Great way to see what servers apps are calling and what data is being passed in the background
http://www.diaryofaninja.com/blog/2010/11/09/using-fiddler-to-sniff-mobile-device-application-traffic
http://www.diaryofaninja.com/blog/2010/11/09/using-fiddler-to-sniff-mobile-device-application-traffic
Saturday, 22 November 2014
How to Host a Primary Domain from a Subdirectory (Using .htaccess)
Like some of you, you may have multiple domain names pointing to different servers, but sometimes, you may wish to have a domain name point to a specific server path (Without URL Forwarding). This post offers a solution on how to accomplish this using a web server that supports .htaccess
Preliminary - What is .htaccess (Read to understand the remainder of this post)
http://en.wikipedia.org/wiki/.htaccess
Modifying the .htaccess
The following code will need to be added to the .htaccess file in the main folder of your web server. You will need to insert the following code block and make modifications as noted in the (#) comments. You will need to change the two instances of example.com to your domain, and the three instances of subdirectory to the folder where you want your site.
Visitors to your Web site will not be able to tell that your main domain is using a subdirectory, they will still see the Web site address as http://www.example.com/page.html.
Please note that this will not work with some website software. You may also need to modify the $base_url, $live_site or other configuration settings to finish the process.
Preliminary - What is .htaccess (Read to understand the remainder of this post)
http://en.wikipedia.org/wiki/.htaccess
Modifying the .htaccess
The following code will need to be added to the .htaccess file in the main folder of your web server. You will need to insert the following code block and make modifications as noted in the (#) comments. You will need to change the two instances of example.com to your domain, and the three instances of subdirectory to the folder where you want your site.
Code Snippet
- # .htaccess main domain to subdirectory redirect
- # Do not change this line.
- RewriteEngine on
- # Change example.com to be your main domain.
- RewriteCond %{HTTP_HOST} ^(www.)?example.com$
- # Change 'subdirectory' to be the directory you will use for your main domain.
- RewriteCond %{REQUEST_URI} !^/subdirectory/
- # Don't change the following two lines.
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- # Change 'subdirectory' to be the directory you will use for your main domain.
- RewriteRule ^(.*)$ /subdirectory/$1
- # Change example.com to be your main domain again.
- # Change 'subdirectory' to be the directory you will use for your main domain
- # followed by / then the main file for your site, index.php, index.html, etc.
- RewriteCond %{HTTP_HOST} ^(www.)?example.com$
- RewriteRule ^(/)?$ subdirectory/index.html [L]
End of Code Snippet
Visitors to your Web site will not be able to tell that your main domain is using a subdirectory, they will still see the Web site address as http://www.example.com/page.html.
Please note that this will not work with some website software. You may also need to modify the $base_url, $live_site or other configuration settings to finish the process.
Sunday, 16 November 2014
CD and DVD File Systems Explained!
ISO9660
The original one that's been around for years and has quite limited functionality.
For Example:
You're limited to 8.3 characters for a file name (i.e. SOMEDOCU.TXT)
You're limited to all uppercase file names.
You're limited to file less than 4GB in size.
Joliet
An extension of ISO9660 and allows for longer / mixed case file names. The file size limit still applies. For Joliet to be used, ISO9660 must also be present - this is reflected in the options available.
UDF
UDF is a file system in it's own right and does not depend on another one also being present.
UDF supports long / mixed case file names and does NOT have the 4GB file size limit of Joliet and ISO9660.
It is the 'better' option for those people using up-to-date operating system. I say 'up-to-date' because older ones like Windows 95 and 98 cannot read / understand the UDF file system and will probably report the disc as being corrupt if that's the only one on it.
Standalone DVD players are only supposed to (made to) understand UDF. Being able to read ISO9660 / Joliet is optional. As such, if you're building a DVD Video disc, you at least want to make sure the UDF filesystem is present in any image you're building / burning.
A typical DVD Video disc you buy from a shop will use 'ISO9660 + UDF', so to be totally correct, that's what you should use too. That way, a standalone player can read it (due to UDF) and PC's with old operating systems can read it (due to ISO9660). A new operating system can read both but will favour UDF because it's more advanced.
More Info Here
The original one that's been around for years and has quite limited functionality.
For Example:
You're limited to 8.3 characters for a file name (i.e. SOMEDOCU.TXT)
You're limited to all uppercase file names.
You're limited to file less than 4GB in size.
Joliet
An extension of ISO9660 and allows for longer / mixed case file names. The file size limit still applies. For Joliet to be used, ISO9660 must also be present - this is reflected in the options available.
UDF
UDF is a file system in it's own right and does not depend on another one also being present.
UDF supports long / mixed case file names and does NOT have the 4GB file size limit of Joliet and ISO9660.
It is the 'better' option for those people using up-to-date operating system. I say 'up-to-date' because older ones like Windows 95 and 98 cannot read / understand the UDF file system and will probably report the disc as being corrupt if that's the only one on it.
Standalone DVD players are only supposed to (made to) understand UDF. Being able to read ISO9660 / Joliet is optional. As such, if you're building a DVD Video disc, you at least want to make sure the UDF filesystem is present in any image you're building / burning.
A typical DVD Video disc you buy from a shop will use 'ISO9660 + UDF', so to be totally correct, that's what you should use too. That way, a standalone player can read it (due to UDF) and PC's with old operating systems can read it (due to ISO9660). A new operating system can read both but will favour UDF because it's more advanced.
More Info Here
Saturday, 15 November 2014
Visual Studio Designer Errors - Could not find type 'CONTROL NAME HERE'. Please make sure that the assembly that contains this type is referenced
Problem
When working with visual development projects in Visual Studio (Can occur in WinForms and WPF applications!), you may encounter a Designer/XAML error such as the following:
To prevent possible data loss before loading the designer, the following errors must be resolved:
Could not find type 'CONTROL NAME HERE'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.
The variable 'CONTROL NAME HERE' is either undeclared or was never assigned.
When these errors occur, typically you may have an error within your application. Simply fix the error, rebuild your solution, and the designer error will disappear! However.... this may not always be the case!
Who What Where Why
In Win Forms applications, Visual Studio keeps a designer file for each Form class within your application. This details where components are laid out of the form, their events, text values and more! (Basically all of their properties). Sometimes, these designer files get a little confused and they cannot sync properly with what the form contains as it's all done automatically behind the scenes. This can happen a lot when using User Controls as the project needs to be built successfully in order for the form to consume the control! (These designer errors may typically reference a User Control a lot of the time).
Resolution
If there are no errors within your application and this error appears, DO NOT EDIT THE DESIGNER FILE! (Never do this for that matter!), Visual Studio should always handle this task. Simply, re-build the whole solution, then restart Visual Studio.
When working with visual development projects in Visual Studio (Can occur in WinForms and WPF applications!), you may encounter a Designer/XAML error such as the following:
To prevent possible data loss before loading the designer, the following errors must be resolved:
Could not find type 'CONTROL NAME HERE'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.
The variable 'CONTROL NAME HERE' is either undeclared or was never assigned.
When these errors occur, typically you may have an error within your application. Simply fix the error, rebuild your solution, and the designer error will disappear! However.... this may not always be the case!
Who What Where Why
In Win Forms applications, Visual Studio keeps a designer file for each Form class within your application. This details where components are laid out of the form, their events, text values and more! (Basically all of their properties). Sometimes, these designer files get a little confused and they cannot sync properly with what the form contains as it's all done automatically behind the scenes. This can happen a lot when using User Controls as the project needs to be built successfully in order for the form to consume the control! (These designer errors may typically reference a User Control a lot of the time).
Resolution
If there are no errors within your application and this error appears, DO NOT EDIT THE DESIGNER FILE! (Never do this for that matter!), Visual Studio should always handle this task. Simply, re-build the whole solution, then restart Visual Studio.
Friday, 14 November 2014
Task.Factory.StartNew (.NET 4.0) and Task.Run (.NET 4.5)
Task.Factory.StartNew (.NET 4.0)
Task.Run (.NET 4.5)
When to use Task.Run and Task.Factory.StartNew
http://blogs.msdn.com/b/pfxteam/archive/2011/10/24/10229468.aspx
Task.Run (.NET 4.5)
When to use Task.Run and Task.Factory.StartNew
http://blogs.msdn.com/b/pfxteam/archive/2011/10/24/10229468.aspx
Thursday, 13 November 2014
c# WPF - Detecting Key Presses - Example: Detecting CTRL+C in a TextBox
The following example allows you to override the keyboard shortcut for copy (Control + C) on the KeyDown event of a WPF TextBox control.
Code Snippet
- private void TEXTBOX_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key == Key.C && Keyboard.Modifiers == ModifierKeys.Control)
- {
- MessageBox.Show("CTRL + C has been pressed!");
- }
- }
End of Code Snippet
Monday, 10 November 2014
Visual Studio Does Not Show Unhandled Exception Message on a 64-bit version of Windows (Silent Exceptions x64)
Silent exceptions on x64 development machines
Have you ever expected an exception to present itself in Visual Studio but the application seemed to play it cool and continue to run (With very unexpected results ensued!)? Then you may have experienced Silent Exception Syndrome! This seems to occur all in 64bit versions of Windows prior to Windows 8 (Vista, 7 etc...)
The Cause
When a user mode exception crosses a kernel transition, x64 versions of Windows do not allow the exception to propagate. Therefore attached debuggers are unaware of the fact that an exception occured resulting in the debugger failing to break on the unhandled exception.
Work Around
This is a known bug with x64 versions of Windows and the way exceptions are handled. One way to work around this issue while debugging is to go to the Debug -> Exceptions and select 'Thrown' for for the exception types you are interested in. This will stop the debugger when the exception is first hit (and before Windows eats it up).
Permanent Fix
Install this Hot Fix
More Information
http://blog.paulbetts.org/index.php/2010/07/20/the-case-of-the-disappearing-onload-exception-user-mode-callback-exceptions-in-x64/
Have you ever expected an exception to present itself in Visual Studio but the application seemed to play it cool and continue to run (With very unexpected results ensued!)? Then you may have experienced Silent Exception Syndrome! This seems to occur all in 64bit versions of Windows prior to Windows 8 (Vista, 7 etc...)
The Cause
When a user mode exception crosses a kernel transition, x64 versions of Windows do not allow the exception to propagate. Therefore attached debuggers are unaware of the fact that an exception occured resulting in the debugger failing to break on the unhandled exception.
Work Around
This is a known bug with x64 versions of Windows and the way exceptions are handled. One way to work around this issue while debugging is to go to the Debug -> Exceptions and select 'Thrown' for for the exception types you are interested in. This will stop the debugger when the exception is first hit (and before Windows eats it up).
Permanent Fix
Install this Hot Fix
More Information
http://blog.paulbetts.org/index.php/2010/07/20/the-case-of-the-disappearing-onload-exception-user-mode-callback-exceptions-in-x64/
Friday, 7 November 2014
C# WinForms and WPF - Getting an Accurate Line Count for a Multline Textbox
You may have used the TextBox.LineCount Property for a standard Textbox control, but you'll quickly notice that if lines overflow onto the next line you'll have an extra line added to your line count. Really, you would like to count every physical line (Which ends in a physical return. I.e. \r\n)
Here is a code snippet that I use, it also ignores empty lines...
Here is a code snippet that I use, it also ignores empty lines...
Code Snippet
- string[] lines = System.Text.RegularExpressions.Regex.Split(MULTILINETEXTBOX.Text.Trim(), "\r\n");
- int lineCount = lines.Length;
End of Code Snippet
Subscribe to:
Posts (Atom)