Friday, 21 December 2012

Web deploy: ERROR_DESTINATION_NOT_REACHABLE.

I wanted to use web deploy from my development PC and build server to the test environment and to production if needed. I have been getting really annoying message:


Web deployment task failed. (Could not connect to the remote computer ("192.168.110.211"). On the remote computer, make sure that Web Deploy is installed and that the required process ("Web Management Service") is started.  Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_DESTINATION_NOT_REACHABLE.)

Great, So what do I do now?

I have checked whether the web deploy is actually installed on my server and I have verified that it is.
As next step I have turned off my firewall and firewall on the server as the message says, not reachable right?.  Test it again and no success.

As next step I have found following guide:
 http://www.iis.net/learn/install/installing-publishing-technologies/installing-and-configuring-web-deploy

From where I have copied steps below:

Trouble-shooting Common Issues:

  • If you are upgrading an existing installation of Web Deploy, make sure to restart the handler and agent services by running the following commands at an administrative command prompt:
  • net stop msdepsvc & net start msdepsvc
  • net stop wmsvc & net start wmsvc
  • Make sure your firewall allows connections to the service you are using. By default, the Web Deployment Agent Service (MsDepSvc) listens on port 80, and the Web Management Service (WmSvc, also called the "handler") listens on port 8172 by default.
  • You must run MsDepSvc by using the built-in Administrator account, or from a domain account that has been added to the Administrators group. A local administrator which is not the built-in account will not work with MsDepSvc.
  • Check to see if .NET 4.0 has not been registered with IIS: Symptoms: .NET 4.0 is installed, but there are no .NET 4.0 application pools or handler mappings in IIS. You cannot browse to applications that use .NET 4.0 (for example, applications based on WebMatrix’s site template applications) after you publish them.
    Cause: Your machine had .NET 4.0 installed on it before IIS was installed.
    Solution: Run the following command to register .NET 4.0 with IIS: %systemdrive%\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -iru


 I only needed to restart all services (first 3 steps) and preview and confirm is working.









Thursday, 20 December 2012

jQuery and Javascript


Here I am adding some memory nudges about javascript and jQuery.


Check for variable is defined


in JavaScript null is an object. There's another value for things that don't exist, undefined. The DOM returns null for almost all cases where it fails to find some structure in the document, but in JavaScript itself undefined is the value used.
Second, no, they are not directly equivalent. If you really want to check for null, do:
if (null == yourvar) // with casting
if (null === yourvar) // without casting
If you want to check if a variable exist
if (typeof yourvar != 'undefined') // Any scope
if (window['varname'] != undefined) // Global scope
if (window['varname'] != void 0) // Old browsers
If you know the variable exists but don't know if there's any value stored in it:
if (undefined != yourvar)
if (void 0 != yourvar) // for older browsers
If you want to know if a member exists independent of whether it has been assigned a value or not:
if ('membername' in object) // With inheritance
if (object.hasOwnProperty('membername')) // Without inheritance
If you want to to know whether a variable autocasts to true:
if(variablename)
I probably forgot some method as well...

Taken from: http://stackoverflow.com/questions/858181/how-to-check-a-not-defined-variable-in-javascript

Wednesday, 12 December 2012

Datepicker date format helper

I have been working on dates and multi language implementation.
I have wrote small class that helps with dates and jQuery.




 
using System.Globalization;
 
namespace HtmlHelpers
{
    public class DateTimeTimeHelper
    {
        /// <summary>
        /// Override jquery date time format with format from current thread.
        /// </summary>
        /// <returns>Javascript format to override jquery date picker settings.</returns>
        public static string OverrideFormat()
        {
            string str = "<script type=\"text/javascript\">";
            str += string.Format("$.datepicker.setDefaults({ dateFormat: '{0}' })"DateTimeTimeHelper.GetDateFormatPatternForCulture());
            str += "</script>";
            str += "</head>";
            return str;
        }
 
        /// <summary>
        /// Get date format pattern for UI culture.
        /// </summary>
        /// <returns>String pattern.</returns>
        public static string GetDateFormatPatternForCulture()
        {
            var dateFormat = GetJavascriptShortDatePattern(System.Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat);
 
            return dateFormat;
        }
 
        /// <summary>
        /// Gets the javascript short date pattern.
        /// </summary>
        /// <param name="dateTimeFormat">The date time format.</param>
        /// <returns>Reformated short date string.</returns>
        public static string GetJavascriptShortDatePattern(DateTimeFormatInfo dateTimeFormat)
        {
            return dateTimeFormat.ShortDatePattern.Replace("M""m").Replace("yy""y");
        }
 
        /// <summary>
        /// Gets the javascript short date pattern.
        /// </summary>
        /// <param name="dateTimeFormat">The date time format.</param>
        /// <returns>Reformated short date string.</returns>
        public string GetJavascriptShortDatePattern(string dateTimeFormat)
        {
            return dateTimeFormat.Replace("M""m").Replace("yy""y");
        }
    }
}

Tuesday, 11 December 2012

OOP JS


Running example for me to learn

Running example http://jsfiddle.net/cpoDesign/Cze3X/6/

Creating OOP for js can be done as following.

var masterPage ={
    confirmBoxMsg: 'Selection not available.',  
    settings:{
        version:0.1,        
        gridSettings:{
            width: 'auto',
            height:'auto'
        }
    },
   
    showAlert: function(){    
        alert('test');
    },
    showAlertWithAttr: function(variable){
            alert(variable);
    },
    showAlertWithFromSettings: function(){
        alert('Reading version:'+ this.settings.version);
    },
    dataAccess:function(url,arguments, complete, errorEvent){
        $.ajax({
            url:url,
            type:'GET',
            data:arguments,
            success: complete,          
            error:errorEvent,
        });
    }   
}

// calls logic in printing
//masterPage.showAlert();
    
// logic with wariable
//masterPage.showAlertWithAttr('variable value');

// logic to read variables from object
masterPage.showAlertWithFromSettings()
    
// using ajax call to do some work (not working yet)
    //masterPage.dataAccess("http://www.google.co.uk/",function(res){
    //alert('loaded' + res.responseText);},function(){alert('failed');});
        
   

Sunday, 9 December 2012

How to set up a split-tunnel VPN in Windows

I always after setting up new VPN connection have to remember to do this. I have saved all article that I have found.


By default, when you create a VPN connection, Windows funnels all of the communications from your computer through the VPN. So, if you're logged into a corporate VPN from home to check your email, all of the other Web surfing you're doing on your computer is also being run through your corporate network. This is the default behavior because, from the company's point of view, it's the safest way and ensures all traffic is protected regardless of the destination.
You might not want this behavior, however, for a couple of reasons. First, it allows your company to inspect all of your personal Web traffic while connected to the VPN. Second, it will likely slow down your access to the Web, as everything must first be sent through the VPN.
Split tunneling, on the other hand, configures the VPN connection so that only traffic headed to computers on the corporate network is sent through the VPN connection. Other traffic leaving your computer goes out through your normal network connection.
Follow these steps to set up a VPN connection in Windows Vista that uses split tunneling:
  1. From the Control Panel, choose "Network & Internet."
  2. Click "View Network Status and Tasks."
  3. Click "Manage Network Connections."
  4. Right-click on your VPN connection and select "Properties."
  5. Select the "Networking" tab.
  6. Highlight "Internet Protocol Version 4 (TCP/IP v4)."
  7. Click "Properties."
  8. Click "Advanced."
  9. Uncheck the "Use default gateway on remote network" box.
  10. Click "OK" three times to close the windows you opened.
From that point forward, only traffic destined for your corporate network will be sent through the VPN. All other traffic will use the local network.

Author and original answer