I have spent the last couple of hours trying to track down the law that states that it is illegal to die in the Houses of Parliament. I have heard about it from a friend, and doing a search on Wikipedia didn't yield any verifiable results.
There are three mentions of this in Wikipedia, two of them linking to two newspaper articles, one stating that this law has been voted the most ridiculous while the other that the practice is to mark St. Thomas' hospital as a place of death in cases anybody breaks the law and dies there. Neither of these articles provide the source, or the actual name of the law that would state this, and I have not found it in neither of the online law databases of the UK I have checked. I couldn't find that law either that would say that those dying in a royal palace have to receive a state funeral, the closest thing was the Coroners Act 1988, that states that inquests into the deaths of persons lying inside one of the Queen's palaces are done by the Queen's coroner; alas no mention of a state funeral.
While the third about Spencer Perceval, the only British prime minister to have been assassinated, while seems to misquote his last words (either, according to the article "I am murdered" or according to the 10 Downing Street website "Oh, I have been murdered") states without providing a source that it is only illegal to die in the House of Lords.
Thus I have to think that this is probably an urban legend, though quite interesting nevertheless. Through my quest I have found the law that states that whales belong to the King.