Invalid Charater Error in Web.config file

Posted by beakersoft | Posted in Programming | Posted on 06-03-2007

0

Had a bit of a problem that was quite easily solved today. I was trying to substitute a curency pound symbol for a euro symbol in a web application, so I decided to make it configurable in the web.config file.
When I added it in however, I kept getting an error saying:

There is an invalid character in the given encoding

If I took out the line, or replaced it with another string, it worked fine. Turned out it was the encoding set in the top of the web config file. I changed to to read:

xml version =”1.0″ encoding=”windows-1252″

And it started to work fine. Not sure what that encoding refers to, but ill find out. I know I should really get the currency symbol from the local of the machine, but I don’t know how!

More on RSS

Posted by beakersoft | Posted in Programming | Posted on 23-02-2007

0

As i discussed in my last posting, I have been doing some work with exposing pages/websites as RSS feeds.

In order to get a website to show the RSS icon (in the URL bar in Firefox, or to activate the feed option in IE7), you need to add the following code to the head tag in the web page:

link rel=”alternate” type=”application/rss+xml” title=”RSS Feed” href=”/RSSFeed.rss”

You can also download all the RSS icons from www.feedicons.com if you want to add any manual links to your pages.

Exposing Data as RSS feed

Posted by beakersoft | Posted in Programming | Posted on 16-02-2007

0

I blogged a week or so about wanting to create an RSS feed using Asp.Net from some stories we hold in a database. Well, today cos i’m off for a week and couldn’t be bothered doing anything else I had a play about with it and managed to get it working.

I downloaded the example that’s part of the Microsoft artical as a starting point (its here:http://msdn2.microsoft.com/en-us/library/aa478968.aspx.). My first problem was the example is written in c#, and i’ve never used that before. Still I rolled up my sleeves and had a go.

The first thing I had to do was alter the SQL it was running, and the database it connected to. So I altered that in the code behind file and ran the page up expecting to be presented with a nice XML file. Of course it didn’t work like that!

I was presented with one of the famous .net error pages, telling me that the Codebehind property of the page directive at the top of the page was no longer supported. I had a surf around and found that it was no longer supported in .Net2.0. I had to use the CodeFile and Inherits directive. So that page directive as a whole looked like this:

<%@ Page CodeFile=”rss.aspx.cs” language=”c#” ContentType=”text/xml” AutoEventWireup=”false” Inherits=”SyndicationDemo.rss”%>

Once I did that, I started getting another error. This time it was down to me not being able to connect to the database. I checked my connection string and it looked ok. I then noticed there was a red error underline in the server name. The server was an instance so it was like news-db\newsdatabase. I remembered back to my limited C++ knowledge about escape character’s, and that a forward slash was used to denote one. Once I put 2 forward slashes in, it started working!

I could now browse to the site, and out came my xml. Needles to say, I was most impressed. Before trying this I’d never programmed in C#, used a data repeater control or output a page in anything but html.

I still have some work to do on the project though. Sometimes there are characters in the story filed that the XML cant handle, I need to strip these out. I need to make it do something in case the page can’t connect to the database or gets an error back when retrieving data. I also want to add one of those RSS icons to the normal PA web application, like the ones that appear in the address bar of other sites. When I get these working ill post anything useful here.

Anyway, I’m of to the dog racing now, hope I done lose to much money.

Listening To: Oasis, Definitely Maybe. What a suburb album, when you don’t hear it for a while you forget how good it is.

Time to Learn

Posted by beakersoft | Posted in Programming | Posted on 08-02-2007

0

Not very much to post at the moment. In the middle of doing a big change to the infrastructure at work. We are moving to a completely new subnet range. Not very complex but taking a lot of planning.

Programming wise started to play about with the asp.net Ajax extensions. Get more info on them here at www.asp.net. The Ajax idea has been around for a while, it just takes existing technology (Java and xml) and puts them in a nice easy to use package. You can now develop very interactive web based applications very quickly. One you get your head round how it all works!!

Also looking at creating an rss feed using asp.net. Our newspaper is trying to get more into the ‘digital’ age, so are throwing around words like rss and pretending they’ve been using it for ages. I’m trying to create an rss feed from the PA (press association) stories we get. I might get some brownie points for it and its quite interesting. A walk though of creating one is at http://msdn2.microsoft.com/en-us/library/aa478968.aspx.

When I get more into both of these things ill post anything interesting on here

Listening to: Little man Tate. Very good and not played enough on the radio. Far better than the View who are getting raved about far to much