Friday 6 March 2009

Tip of the Day: saving web.config as Unicode

Today's lesson: if you need to edit your .Net web.config file, think twice before doing it in anything but Notepad. If you have edited web.config in another application, it might be saved as ASCII, not Unicode.

The error on your site may be something like:
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: There is no Unicode byte order mark. Cannot switch to Unicode.

Source Error:


[No relevant source lines]


To fix this, open the web.config in Notepad, choose 'Save As' from the File menu. In the 'Save As' dialogue box, make sure the filename is web.config, 'save as type' is 'All files' and Encoding is 'Unicode'.

There are probably other ways of fixing the error, but this is the 'lowest common denominator' fix, and if you're racing to get a live server back up, Notepad might be all you have.

I should point out that I didn't discover this by bringing the live web server down, so if you work for the Science Museum, don't panic!

2 comments:

  1. Nice.. troubleshooting info. Thanks lot.. I googled for the solution of this issue, finally got from your blog. Thank you so much.

    ReplyDelete
  2. Thanks for letting me know - I'm glad it's helped someone else.

    ReplyDelete

Play nice!