Wednesday, September 12, 2012

Using Windows 8 Remote Desktop Over VPN

After upgrading to a Windows 8 on my office workstation, I’ve had trouble connecting from home over the VPN. The problems have included “Licensing Timed Out” errors and black screens. After some digging around, I found that this problem can be caused by packet fragmentation.

Using a VPN takes up a few bytes in each packet, and so if the original packet size is close to the maximum size for a packet (Max MTU) then fragmentation will occur. RDP forbids packet fragmentation, so will fail if one of the intermediate hops supports fewer bytes per packet than the client.

The solution I found is to reduce the maximum packet size for my network adapter so that the original packets fit within the VPN packets produced by my router. This affects all network traffic, but the packet size only needs to be reduced by a few bytes, so this isn’t much of an issue.

(This forum post was the source of some of the following details).

To find the largest packet size that is suitable for your VPN, run a ping against a computer at the other end of the connection. Use the “-l” option to change the size of the packet that is sent, and the “-f” option set the do-not-fragment bit.

ping –l 1500 –f <hostname>

If the ping produces a fragmentation error, then reduce the size of the packet until the ping is successful. This is likely to be 1472 bytes if the VPN overhead is the source of your problems.

I’m using Windows 8 on my home workstation, so the MTU setting can be changed using a PowerShell command:

PS> get-netipconfiguration

This will list all the network interfaces on your computer, including a column named “NlMtu” which is the maximum packet size. In my case, the main network interface was named “Ethernet” and had an NlMtu value of 1500.

PS> set-netipconfiguration –interfacealias Ethernet –nlmtu 1472

Of course, you might need to replace the interface name and MTU values in the previous command with values that are appropriate for your settings.

Sunday, March 27, 2011

Using MvcBuildViews with One-click Publish and Deployment Packages

ASP.NET MVC Web Application project files (MVC 2+) have the ability to compile your view code when the rest of your application is compiled. Enabling this functionality requires manually modifying the project file. Read Compiling Views in ASP.NET MVC for a quick overview of how this can be achieved.

This is a great way of catching basic coding errors before the affected view is reached by a browser. It’s exacly the kind of thing you want to include in your build process – which might also include the creation of a deployment package the new MSDeploy-based packing in Visual Studio 2010.  Unfortunately there is a conflict between MvcBuildViews and Deployment Packages. Fortunately the fix is simple enough, just add some dependencies to the MvcBuildViews target so that any leftover packaging files are cleaned up before the MvcBuildView target executes.

<Target Name= "MvcBuildViews"
        AfterTargets= "AfterBuild "
        Condition= "'$(MvcBuildViews)'=='true'"
        DependsOnTargets= "CleanWebsitesPackage;CleanWebsitesPackageTempDir;CleanWebsitesTransformParametersFiles;"> 
    <AspNetCompiler VirtualPath= "temp " PhysicalPath= "$(MSBuildProjectDirectory) " /> 
</Target> 
 
 

Wednesday, February 6, 2008

ASP.NET Futures in Visual Studio 2008

After recently installing VS2008 I decided that it was time to start diving deeper into ASP.NET AJAX.

One of the design options for a project I am working on is to use drag-and-drop to perform various tasks. This article describes how to implement a simple drag and drop behaviour.

What the article doesn't describe is how to get the Visual Studio environment set up to enable these behaviours.

I knew from previous visits to http://asp.net/ajax/ that this part of the ASP.NET AJAX Framework has been separated into an ASP.NET Futures CTP which was available for download from the above website. However, the link no longer exists on the home or download pages. Quickstarts are available although they are not easy to find.

The ASP.NET AJAX site now links to the Microsoft ASP.NET 3.5 Extensions Preview. Although this package does include certain updates to the AJAX framework (such as History support) it does not include the features from the ASP.NET Futures CTP.

I tried to find a recent statement on the future of the Futures CTP but didn't manage to find one. The CTP is still available for download, and although it is labelled as the July 2007 CTP it was in fact updated in December to work with VS2008 RTM. I guess that this is a sign that it is still being worked on.

Anyway, back to getting the drag and drop sample to work. The following steps are required to get Jeff Prosise's sample to work in VS2008 and, although I haven't tried it, VS2005.

  1. Download the ASP.NET Futures CTP (July 2007). If you downloaded it prior to December then download it again so that you get a copy that works with VS2008 RTM.
  2. Create a new ASP.NET Futures Web Application project. If you have an existing project then add a reference to Microsoft.Web.Preview.dll.
  3. Create a dragDropTest.js file that contains Jeff's sample code. You will also need to add the following line to the top of the file:

    Type.registerNamespace('Custom.UI');

    Add the following line to the bottom of the file:

    if(typeof(Sys) !== 'undefined') { Sys.Application.notifyScriptLoaded(); }

  4. Add a ScriptManager component to your aspx page if you haven't already. Add the following script references in this order:

    <Scripts>
    <asp:ScriptReference Name="PreviewScript.js" Assembly="Microsoft.Web.Preview" />
    <asp:ScriptReference Name="PreviewDragDrop.js" Assembly="Microsoft.Web.Preview" />
    <asp:ScriptReference Path="~/DragDropTest.js" />
    </Scripts>
  5. Run the project, and start dragging and dropping!

Wednesday, January 16, 2008

AppleMobileDeviceHelper Crashes iTunes 7.6

I just installed the latest iTunes 7.6 release. Now when I start iTunes I get a constant stream of "AppleMobileDeviceHelper has stopped working" messages. I don't have an iPhone or an iPod Touch so the simplest solution was to go into Programs and Features (Add/Remove Programs in earlier versions of Windows) and uninstall "Apple Mobile Device Support".

No doubt the next upgrade of iTunes will put it right back in there.

Thursday, November 29, 2007

Hello World

Not a very original title or subject for my first post, but I wanted to test out Jeff Atwood's FormatToHtml macro. I plan on making lots of use of it in future posts as I write about some projects I've been working on.

using System;

namespace HelloWorld
{
   
class Program
    {
       
static void Main(string[] args)
        {
           
Console.WriteLine("Hello World");
        }
    }
}