Recent Updates RSS Toggle Comment Threads | Keyboard Shortcuts

  • John 2:21 am on January 9, 2012 Permalink | Reply
    Tags: , , Web Farm Framework   

    Failed to run method ‘Microsoft.Web.Farm.SyncApplicationsRemoteMethod’ on server 

    I have currently been having an issue with Web Farm Framework 2 not provisioning my applications correctly. I would receive and error message saying that it could not delete the temp app pool file on the secondary server.

    Failed to run operation 'ProvisionApplications'.
    Failed to run method 'Microsoft.Web.Farm.SyncApplicationsRemoteMethod' on server 'xx.xx.xx.xx'.
    Exception in response stream. An error was encountered when processing operation 'Delete File' on 'APCE41E.tmp'.
    The error code was 0x80070020.
    The process cannot access 'C:\inetpub\temp\appPools\APCE41E.tmp' because it is being used by another process.
    Exception in response stream. An error was encountered when processing operation 'Delete File' on 'APCE41E.tmp'.
    The error code was 0x80070020.
    The process cannot access 'C:\inetpub\temp\appPools\APCE41E.tmp' because it is being used by another process.
    

    This can be resolved by ignoring the appPool temp files from the sync. To do edit the the ignore list in c:\windows\system32\inetsrv\conf\applicationHost.config on the web farm controller so that the web farm includes the following skip directives.

    <webFarm>
      <applicationProvision offlineWhileSync="true" syncWebServerFromPrimary="true" periodicSync="00:00:30">
        <clear />
        <skipDirectives>
          <skip name="appPools" skipDirective="objectName=dirPath,absolutePath=.*appPools.*" />
          <skip name="logFiles" skipDirective="objectName=dirPath,absolutePath=.*LogFiles.*" />
        </skipDirectives>
      </applicationProvision>
    </webFarm>
    
     
    • Kris Van de Vijver 11:26 am on January 10, 2012 Permalink | Reply

      Good to know there’s a skip list for this. Thanks..

  • John 11:57 pm on January 8, 2012 Permalink | Reply
    Tags: Amazon, Backup, , , S3   

    Backup IIS Server Package to Amazon S3 using C# 

    I recently updated our backup process at work to store our backups on Amazon S3. I wanted a simple process to that would backup the IIS server configuration and website files that can be easily be restored on a new server in case of a major problem. Luckily Microsoft have release MSDeploy which can be installed using the Web Platform Installer.

    Within IIS you can backup everything to a server package by opening the context menu selecting depoy, then “Export Server Package”. This will create the server package containing the IIS configuration along with all the sites and their files. This is all good however it is still a manual process that is likely to be forgotten about after a while. Likely there are a series of libraries we can use to automate this process.

    The namespace Microsoft.Web.Deployment provide the functionality we need to backup IIS, this is provided by Microsoft.Web.Deployment.dll. To backup the server we need to use the DeploymentManager to create an object use to create the package, we can then use this to “sync” the server setting to a package.

    After we have backed up the site package we need to upload it to Amazon S3. To do this we can use the AWSSDK .NET library. The library can be installed via NuGet by searching for “AWS SDK”. This will install the required assemblies.

    We can use the AWS SDK to upload our server package zip to S3 using the TransferUtilityUploadRequest to create our request to use with the TransferUtility to upload our file.

    When this is all tied together we have an app that will backup and upload the server package to S3.

    I have attached a sample app that can be configured using the App.config

    Download yeticode-utility.zip

     
  • John 1:03 am on January 4, 2012 Permalink | Reply
    Tags: , , , MVC3   

    MVC Update User Online via Action Filter 

    Action filter to update the currently logged in users last online time to allow you to identify which of your users are online

    /// <summary>
    /// User Online Action Filter Attribute
    /// </summary>
    public class UserOnlineActionFilterAttribute : ActionFilterAttribute
    {
        /// <summary>
        /// Called by the ASP.NET MVC framework after the action method executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            try
            {
                if (filterContext.HttpContext != null && filterContext.HttpContext.User != null && filterContext.HttpContext.User.Identity != null)
                {
                    Membership.Provider.GetUser(filterContext.HttpContext.User.Identity.Name, true);
                }
            }
            catch
            {
                // BAD: Swallow the exception to prevent it messing with the users action
            }
    
            base.OnActionExecuted(filterContext);
        }
    }
    

    Add the action filter to the global list inside the global.asax Application_Start.

    GlobalFilters.Filters.Add(new UserOnlineActionFilterAttribute());
    
     
  • John 10:42 pm on May 30, 2011 Permalink  

    Gnome 3 – Stupid Power Options Fix 

    Upgraded to Fedora 15 and Gnome 3 everything is working well and the new interface is looking slick. The gnome guys have done a very good job and am very impressed. However I have come across on thing that, for a while, really pissed me off. They removed the ability to easily change the power options when you close the lid on your laptop. The default option is to suspend the computer. This isn’t a problem for a lot of people, even if there is a bug on the dell M1330 laptop which causes a crash when starting from a suspended state. I digress, a lot of work has done into this and has already been discussed in detail.

    http://blogs.gnome.org/hughsie/2011/02/02/is-gnome-3-going-to-melt-your-laptop/

    http://afaikblog.wordpress.com/2011/02/03/on-laptop-lids-and-power-settings/

    http://live.gnome.org/Design/SystemSettings/Power

    However all the discussion did not cover my use case, which occurs on a daily basis:

    1. Play audio book.
    2. Run command to shutdown laptop after half an hour.
    3. close laptop lid turn off lights and go to sleep.

    You can resolve this using the solution, provided by timlau, to use gsetting to manually set the power setting (He post links to a script to automatically set this using a zenity dialog).

    gsettings set org.gnome.settings-daemon.plugins.power lid-close-ac-action “blank”
    gsettings set org.gnome.settings-daemon.plugins.power lid-close-battery-action “blank”
    

    End Rant.

     
    • Drew 11:10 am on October 22, 2011 Permalink

      There’s a separate options tool available now that fixes the problem: gnome-tweak-tool

  • John 12:03 am on May 18, 2011 Permalink | Reply  

    Adventures Into Web Farm Framework 2.0 

    I have been using the Web Farm Framework 2.0 to handle the load balancing and provision of the applications. Our web farm consists of four servers, 1 load balancer, 2 web servers and 1 database server. The installation was simple enough using the Web Platform Installer.



    The web platform installer was used to install the Web Farm Framework 2.0 onto the load balancer. The guide “Setting up a Server Farm with the Web Farm Framework 2.0 for IIS 7” provides an easy walk through for getting your web farm setup. However once it has been setup there are a number of steps that still had to be configured to ensure the web farm worked correctly.

    Before completing the following steps I ran into a an issue where the server would appear available for load balancing in the “Servers” view, but would be unavailable in the “Monitoring and Management” view. To resolve try the following steps.

    1. Health Test Url

    Make sure that the health test url has been set. The application request routing uses this to test whether a server should be used for load balancing.



    2. Default App Pool Settings

    Edit the advanced settings of the DefaultAppPool on the controlling server and set the recyling value for “Regular Time Interval (minutes)” to zero.



    3. Set Primary and Secondary Servers to Response to Ping

    Update the firewall settings on the Primary and Secondary servers to respond to ping.



    These are thing steps that I followed to get it to work correctly, they might vary for you depending on your setup.

    Related Reading


     
    • Kris Van de Vijver 11:24 am on January 10, 2012 Permalink | Reply

      Hi John, we have the same problem. Did these steps solve the issue permanently for you?
      Thanks.

  • John 11:05 am on March 10, 2011 Permalink | Reply
    Tags: , IIS Express, ,   

    IIS7 & IIS Express 401 Access is denied due to invalid credentials Issue 

    I have been working on a large web application using MVC3, NHibernate using IIS Express to debug and IIS7 to stage. I’m using the membership services provided by ASP.NET to handle user authentication and provide security to the system. However I kept running across an issue, when accessing remotely, that was preventing me from logging in. Whenever I tried to view a page as a non logged in user I was returned a 404 Unauthorized error.

    401 - Unauthorized: Access is denied due to invalid credentials.

    401 - Unauthorized: Access is denied due to invalid credentials.

    After searching around for a solution to why this was not displaying the correct page, even if it was redirecting to the login page I decided to try to set the error displaying to return more information. After adding <httpErrors errorMode=”Details” /> to try and get a detail output from IIS the page started to work as expected.

    With this option enabled the login page was now correctly displayed. This can be set without having to edit the web.config on IIS7 by editing the “Error Pages” features settings for your site in IIS. Set the Error Response to “Detailed errors”

    Related Reading


     
    • John 3:53 pm on March 22, 2011 Permalink | Reply

      Thanks for this post! I ran into the same problem. This seems a little odd to me, have you figured out why MVC3 is exhibiting this behavior?

      • John 4:13 pm on March 22, 2011 Permalink | Reply

        Figured out what is going on… this serverfault answer is the perfect explanation:

        http://serverfault.com/questions/137073/401-unauthorized-on-server-2008-r2-iis-7-5

        In my case, I had a logon page calling Html.RenderAction(), and that action had an [Authorization] attribute.

        Cheers.

        • John 4:17 pm on March 22, 2011 Permalink | Reply

          Sorry… [Authorize] :-)

          • John 8:24 pm on March 22, 2011 Permalink | Reply

            Cheers for the update, I’ll have to take a closer look I also have numerous Html.RenderAction() that properly implemnt the [Authorize] attribute.

            However I only noticed it since MVC3 RC, I don’t think it was in either of the previous of the beta versions.

    • erick 3:31 am on August 22, 2011 Permalink | Reply

      thx alot, it help me alot..i try to figure this out for 6 days :(

    • Ryan Faricy 5:44 am on December 14, 2011 Permalink | Reply

      I can confirm that a path leading to an eventual [Authorize] attribute causes this – removing the RenderAction or allowing that action to render without [Authorize] fixes it.

  • John 1:56 pm on August 25, 2010 Permalink | Reply
    Tags:   

    Javascript string.format 

    String.prototype.format = function () {
        formatted = this;
        for (i = 0; i < arguments.length; i++) {
            formatted = formatted.replace("{" + i + "}", arguments[i]);
        }
        return formatted;
    }
    
     
  • John 10:06 pm on June 16, 2010 Permalink | Reply
    Tags: triathlon   

    My First Triathlon 

    So last Sunday I did my first sprint triathlon, the Mid Sussex Triathlon. The day started at 5.00 when me and Tom woke up to a quick breakfast and a cup of tea. A short drive to the Triangle Leisure Centre in Burgess Hill and we were set to have our numbers draw on us in the strongest permanent marker in the world (Which took 3 days to wash off). After registration we took our carefully packed tri boxes and bikes to the transition area.

    After laying out my foot towel in the perfect foot drying position and my helmet, shades and top in the most efficient way possible. All this in the vein hope that when it came to the actual transition I would have some clue what the hell I was supposed to be doing.

    Stuff sorted we waiting casually chatting with the other competitors about the course and general pre-race banter. Ranging from our kit to subtle ways to psych one another out. After the race briefing the first swimmer started at 7.00. Me and my brother took a walk to the observation deck in the pool to watch the starters. This was when the nerves started to kick in.

    More and more of the swimmers started my start time neared and my position in the line grew shorter. With only four competitors I turned to my brother, now feeling really nervous, and said “Whose stupid idea was this?”

    Swimming Section

    There was no one in front of me and I was in the pool. Three. Two. One. I was off. Nothing quite prepared myself from going from full of nerves to race mode. Halfway down the first length my body woke up and all the training I had done kicked in. No longer nervous. A single thought in my mind. Swim straight, don’t drown don’t waste to much energy.

    The final length of the swim drew to a close and it was time to get out of the pool. Using the steps, as not to make a tit of myself if i fell over, I pulled myself out and started the run to the transition area to get ready for the bike ride. I had no idea what the hell I was supposed to be doing. I got to the transition area remembering only one thing. Make sure you helmet is on before you touch your bike. I stand on the towel, move my top out of the way and put my helmet on it. Pick up top and realise that I need to take my helmet off, put my top on, put my helmet on and step into my shoes. Now its time to pick up my bike and run with it to the mounting area. Enter the mounting area mounting my bike and start to ride narrowly missing a woman trying to get her bike into gear. A luck escape as I don’t think she would have been too happy if I had ridden into her. Exiting the leisure centre the race portion begins.

    Section Two - The Ride

    For the majority of the bike ride there was nothing to worry about. A side from needing to practice on gear changes on the hills it all went fairly well. I was taken back a few times as the more experienced competitors, on really expensive bikes, wizzed past me closer than I expected. But after the first couple of times that happened I started to check behind me more often so that I knew who was behind me, and so that I wasn’t causing an obstruction people who were clearly better than me. Like the people who overtook me on the steep up hill sections.

    With the bike section drawing to a close I changed down gears to try and warm up my legs ready for the run. In my haste I changed down to many gears and was left coasting with my legs spinning around aimlessly. Coasting into the dismount area I jump off my bike and run it back to my place in the transition area to rack it up. Throwing my helmet into my box and picking up a bottle of water I head out for the final section, the run.

    Leaving the transition area water bottle in hand I start the run. My legs feeling heavy from the cycle I knew it would only be a little longer before they would feel normal again. The run went fine with brownies lining the route with list of everyone’s names and numbers ready to cheer you on just when you need it. With the final stretch drawing to a close, the cheers from the brownies getting louder and the finished line getting closer it was time to muster the last of my energy. It was time for a sprint finish. My legs where not quite feeling up to the job. Then I spy my bother, who had already finished waiting on the finish straight. I hold my arms out for a high five. High five received I now have the energy, pulled from the ether, to sprint the last little bit to the finish. Crossing the line and stopping my watch. Covered in sweat and in dire need for a shower and a cup of tea I look down at the time. 1:19:55. Happy that my first triathlon went better than my first marathon.

    The Finish Line

     
  • John 11:26 pm on April 26, 2010 Permalink | Reply
    Tags: bzr, , ontime, ,   

    Bazaar Plugin for OnTime Integration 

    I was playing around with bazaar, whilst reviewing distributed version control systems (DVCS), and created a simple plugin for use with axosoft’s ontime. The plugin parses the commit message and links the files to the related task, defect or feature.

    Install

    Download the tar file from [download id="3"]
    Extract and run the installer using the following:

    tar -vxzf bzr-ontime-0.0.1.tar.gz
    cd bzr-ontime-0.0.1
    sudo python setup.py install
    


    Configure

    Setup the database connection information.
    /etc/bzr-ontime.conf

    [ontime]
    server=your-mssql-server
    username=sa
    password=p4ssw0rd
    database=ontime
    


    Confirm Installation

    bzr hooks
    

    If the plugin is installed correct you should see the plugin listed under the post_commit section.

    Related Reading

     
  • John 12:34 am on March 28, 2010 Permalink | Reply
    Tags: , Castle, Medium Trust, NHibernate   

    Running NHibernate in Medium Trust 

    After deploying a NHibernate to a shared host I started running into a number of issues. Whilst developing we were running in full trust not in medium trust whilst the majority of shared hosts use. After hours and hours of searching I finally come across a post on the Castle Project mailing list which detailed how to get a nhibernate working under medium trust. Here is the steps I followed to get it working.

    I am using NHibernate 2.1.2 and C# .NET 3.5 in Visual Studio 2008.

    Step 1

    Download Castle.Core from gitbhub
    git://github.com/castleproject/Castle.Core.git

    Step 2

    Enable Castle to allow partially trusted callers.
    Open buildscripts/CommonAssemblyInfo.cs and enable the library to enable partially trusted callers

    Step 3

    Disable generation of debug information for the projects Castle.Core and Castle.DynamicProxy.

    Step 4

    Build the projects

    Step 5

    Download Nhibernate source code from source forge.

    http://sourceforge.net/projects/nhibernate/files/

    Step 6

    Open Nhibernate.Everything.sln and update the references for the NHibernate.ByteCode.Castle project so that the references for Castle.Core and Castle.DynamicProxy2 are the libraries build in step 4. Disable generation of debug information for the projects NHibernate, Iesi.Collections and NHibernate.ByteCode.Castle, similar to what was done in step 3.

    Step 7

    Copy the outputted library files from NHibernate.ByteCode/bin/Release to your shared libs folder of your project.

    Step 8

    Update the references in your project to point to the new libraries. Next turn off reflection optimization. This needs to be done in code before you create the configuration object. Configuring this in the hibernate.cfg.xml does not work. Update all your projects assemblies to set allow partially trusted callers, similar to step 2. Update your web.config to set requirePermission=”false” in the nhibernate section delceration

    NHibernate.Cfg.Environment.UseReflectionOptimizer = false;
    Configuration = new Configuration();
    Configuration.Configure();
    
    
    

    You can now run your site in medium trust using lay loading.

    Links

    Related Reading

     
    • Curtis Gulick 4:45 am on June 17, 2010 Permalink | Reply

      Can you post a full zip of your solution for both castle and NHibernate with the changes applied? I cannot seem to find the same version of castle.core that you used. I got a vs2008 and vs2010 version, but both have significant changes that do not work with nHibernate directly. Thank you!!

    • John 2:36 pm on June 20, 2010 Permalink | Reply

      Here is a version that I compiled to work view .NET 2.0

      http://blog.yeticode.co.uk/wp-content/plugins/download-monitor/download.php?id=4

    • Bri Manning 8:49 pm on September 5, 2010 Permalink | Reply

      Hey John,

      Having the same issue as Curtis and that download link appears to not be working. I’d be awesome if you could put them in another location. All I’ve been able to find are the 2010 files. Thanks!

    • John 10:56 pm on September 5, 2010 Permalink | Reply

      They should be accessible from here, the plugin was using to sort out downloads broke.

      http://blog.yeticode.co.uk/wp-content/uploads/downloads/2010/06/libs.zip

    • Bri Manning 8:07 pm on September 8, 2010 Permalink | Reply

      Awesome! Thanks, John.

    • Sara 7:41 am on September 24, 2010 Permalink | Reply

      John on behalf of everyone out there who read your post and DID NOT want to do all of that…..thank you, thank you, thank you and THANK YOU!!!

    • Dejan.s 4:14 am on September 30, 2010 Permalink | Reply

      Thanks. I don’t get the last part of it.. where should I put the Nhibernate.Cfg…… and the web.config section where should it go? I really dont got anything in my web.config for my nhibernate. I use fluent nhibernate and dont got no xml files at all its all classes..

    • Lakshmish 7:34 am on November 16, 2010 Permalink | Reply

      I tried using the library provided, but still issue persists

      have this in web.config

      and following in hibernate.cfg.xml….

      Exception Details: System.Security.SecurityException: Request for the permission of type ‘System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.

    • Lakshmish 7:36 am on November 16, 2010 Permalink | Reply

      tags made content not to appear….

      hibernate.cfg.xml ……….. have ……. reflection-optimizer use=”false”
      web.config ………… section name=”hibernate-configuration” type=”NHibernate.Cfg.ConfigurationSectionHandler, NHibernate” requirePermission=”false”

c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
esc
cancel