Newbie simple question

  • Thread starter Thread starter joe
  • Start date Start date
J

joe

I have trouble getting my "Hello world" test aspx page working.

I have a home page on a Windows server (a web hotel). Other HTML pages run fine
there. I tried an aspx page just to test C# but I get an error "Server Error in
'/' Application". What am I doing wrong? I've copied the Default.aspx and
Default.aspx.cs to my web page.

The page is simple enough:
Default.aspx:
//---------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Just a test</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Hello there
</div>
</form>

</body>
</html>




And here's the Default.aspx.cs:
//---------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

Response.Write("Hello world");
}
}



When I run it from MS Visual Web Developer 2005 express edition I run just fine.
IE page is opened and I see Hello there and Hello world.
 
I would check that your web server is set up to use ASP.NET 2.0 for
your web app. That is a common cause of this error.
 
Jacob said:
I would check that your web server is set up to use ASP.NET 2.0 for
your web app. That is a common cause of this error.

Thanks. How do I check that?

I ran this code and it performed OK.:

<%@ Language="javascript" %>
<html><body><form>

<h3>Hello world!!! This is an ASP page.</h3>

<% Response.Write("This content was generated ");%>
<% Response.Write("as part of an execution block")%>;

</form>
</body></html>
 
I would check that your web server is set up to use ASP.NET 2.0 for
Thanks. How do I check that?

In IIS management, right click on the relevant application, choose
properties, then ASP.NET tab; check the version number is
2.0.<something>. If the ASP.NET tab does not appear in the property
pages [unlikely], or there is no option for version 2.0 [more likely],
you need to register ASP.NET with IIS: run aspnet_regiis -i from a
command prompt (the utility is in the c:\windows\microsoft.net\<your
version> folder).

If that doesn't help, try and get more information on the error that's
occurring, and post it here. If the browser tells you nothing more than
you posted ('Server Error') then check out the IIS logfile and the
Windows Event Log.

HTH

-- ph
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top