Depending on where and when you load your code, it could cause an error and the page won't load at all. A better approach would be something like this with some error handling in it:
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (CurrentDocument != null)
{
if(CurrentDocument.DocumentName== "home")
{
CMS.DocumentEngine.DocumentContext.CurrentBodyClass += " body-home";
}
else
{
CMS.DocumentEngine.DocumentContext.CurrentBodyClass += " body-page";
}
}
}
</script>
You might also want to add a field to the page type(s) which will allow the user to set the CSS class name from within the form data. Then you don't need to hard code what css class is being used, you simply use the setup like below:
CMS.DocumentEngine.DocumentContext.CurrentBodyClass += " " + CurrentDocument.GetStringValue("YourCssClassColumnName", "body-page");