Http Error 503 – Service Unavailable with .NET 4 – #IIS

When trying to debug my web service today after upgrading the project to .NET 4, I was told by Visual Studio that it could not debug and to try running the project outside the browser. When I did, I received a 503 Error, Service Unavailable.

I check the Event Log and found this:

The worker process for application pool 'PartsWebService' encountered an error 'Cannot read configuration file due to insufficient permissions
' trying to read configuration data from file '\\?\C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\machine.config', line number '0'. The data field contains the error code.

Simple enough, I just have to give the correct permissions to that file. It seems that my service’s application pool identity doesn’t have rights. So I’ll navigate to the path that contains the machine.config and set permissions there.

You can’t just set permissions on the parent folder, you have to give permissions to the machine.config file itself. Add IIS_IUSRS from your local machine to the read and execute roles.

Also, load IIS Manager and check your application pool as this error usually stops the application pool if it’s running.

This should clear up any issues you were having.

More #Illustrator and #Lightroom Goodness – Image Trace

Laurie

I really like the image trace functionality in the new Illustrator CC. I took a photo of Laurie and did some alterations in Adobe Lightroom to increase the contrast and make it a better candidate for image trace. I then loaded it in Illustrator and applied the image trace to it. Then I added the fill color to her face. It was so incredibly simple. It’s amazing to me that this illustrator file can now be used to create an image of any size and not lose resolution. It could even be on a billboard! I love Illustrator.

Here is the original image:

Laurie

First project with Adobe #Illustrator CC

Laurie’s new job has her teaching preschool at the Jewish Educational Alliance here in Savannah. As part of her teaching, she needed a wheel that would let her students know what the day’s activity would be. I decided to create it for her using Adobe’s new Illustrator Creative Cloud.

Here is a PDF containing the final product: ActivityWheel

Activity Wheel

Most of the work I did involved finding Creative Commons images on the web and converting them to line drawings, then cleaning up the paths.

The activities are:

  • Monday – Sandbox
  • Tuesday – Painting
  • Wednesday – Skating
  • Thursday – Water table
  • Friday – Spray Painting (with paint in a spray bottle)

I really like the new Illustrator. I still haven’t decided if I can pay the $20/month for it, though. I have the Photoshop/Lightroom special of $9.99/month already.

Enabling Basic Authentication for Angular and jQuery clients for your ASP.NET WebApi

I have been working on a WebAPI for a client over the past few months and I’ve successfully implemented Basic authentication on my WebAPI and connected to it using a Xamarin Android client.

I’ve come to a point where I need to start supporting AngularJS clients, but I don’t like how the browsers each have their own default login dialogs that are ugly. I found a great blog entry solving this exact issue, but the author wrote their server side in Sinatra.

Here is the blog entry with the situation and solution:

http://olefriis.blogspot.com/2014/01/http-basic-authentication-in-angularjs.html

You’ll need to implement Basic authentication on your WebAPI to make this work. To implement Basic authentication on your ASP.NET WebAPI, follow the instructions here:

http://www.asp.net/web-api/overview/security/basic-authentication

One thing to make sure you do (in Web.config) is change the

type="WebHostBasicAuth.Modules.BasicAuthHttpModule, BasicAuth"

to reflect the project name and binary name of your project (your’s shouldn’t be named WebHostBasicAuth.Modules.BasicAuthHttpModule. It will be the name of your project instead.

type="{ProjectName}.Modules.BasicAuthHttpModule, {BinaryName}

It turns out that the changes required to make the solution outlined in Ole Friis Østergaard’s post is very easy to implement in ASP.NET.

Here is the code you need to change in the Basic Authentication Implementation from above:

That’s it! Now, when you pass in the X-Requested-With header value of “XMLHttpRequest”, you’ll get back a WWW-Authenticate header with a type of “xBasic” instead of “Basic”. That will cause the browser to ignore the request and suppress the login dialog, letting you display your own pretty dialog.

I have started a GitHub project that has my Sample WebAPI in it. I’ll be updating that to include the AngularJS code as I create it to demonstrate exactly how to pull this off since Ole’s post is light on details.

Here is the GitHub project:

https://github.com/cerkit/BasicAuthWebApiSample.git

IIS Error Message – An attempt was made to load a program with an incorrect format.

If you receive the following error message when running a website (usually after deploying onto a 64-bit machine):

Could not load file or assembly ‘PROJECTNAME’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

It could indicate that your web app (or one of its dependencies) was built for x86 and 32-bit applications are turned off in your application pool.

  1. Open IIS Administration Tool
  2. Click on sites
  3. Click on the site you’re trying to run
  4. On the right side, click on “Advanced Settings”
  5. A dialog box pops up with information about the site in it
  6. Look for the name of the Application Pool
  7. Close this window
  8. Click on “Application Pools” in the tree on the left
  9. Click on the Application Pool from the screen you just looked at
  10. Click on “Advanced Settings” on the right
  11. Look at the value for “Enable 32-Bit Applications”
  12. Make sure this is set to True (it is False by default)

You could also recompile your project for x64, but any dependencies you have might not work.

random musings

Follow

Get every new post delivered to your Inbox.