473,405 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Getting Started Question

I am trying to learn C# over the internet. My ISP only allows .aspx
files. All .cs files are rejected.

The tutorials on the Internet are aimed at people able to run .cs
files from the command line. I can't do this.

Here's an almost universal first example.

using System;
class HelloWorld
{
public static void Main()
{
Console.WriteLine("Hello World !");
}
}

I've modified it to this and saved it as test.aspx but it doesn't run

<%@ Page language="c#" Debug="true"%>

<script Language="c#" runat="server">
using System;
class HelloWorld
{
public static void Main()
{
Response.Write("Hello World !");
}
}
</script>

I can't figure out what I'm doing wrong. Shouldn't all C# programs be
able to run in an .aspx file using Response.Write instead of
Console.WriteLine?

Thanks in advance for any help.
Nov 16 '05 #1
2 1080
Cyril Kearney <cy***********@hotmail.com> wrote:
I am trying to learn C# over the internet. My ISP only allows .aspx
files. All .cs files are rejected.

The tutorials on the Internet are aimed at people able to run .cs
files from the command line. I can't do this.
Any reason you can't install the .NET framework on your own computer
and compile and run your own programs?
Here's an almost universal first example.

using System;
class HelloWorld
{
public static void Main()
{
Console.WriteLine("Hello World !");
}
}

I've modified it to this and saved it as test.aspx but it doesn't run
<snip>

No, it wouldn't.
I can't figure out what I'm doing wrong. Shouldn't all C# programs be
able to run in an .aspx file using Response.Write instead of
Console.WriteLine?


No. ASP.NET works on pages, not programs - the above is a program, with
a program entry point (Main).

I suggest you try to find an ASP.NET tutorial instead of a plain .NET
tutorial. However, without being able to include code-behind pages,
you're going to get frustrated pretty quickly, I suspect.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
It does not run, because you put a class, into a server side script and
expect the Main function to run. Do not confuse a console application
(which is a standalone application), with an asp.net page (which is just a
page executed by the aspnet process - which is an application).

That being said, what you can put in a server side script block like that
are functions. These function can be event handler for events - in which
case they will run when the event occurrs. Or they can be regular functions,
which will be run when you call them (from an event, or an inline script
block).

You can also use <% %> server side script blocks, which can contain lines
of code. So something like:

<%
Response.Write("Hello");
%>

I recommend you get familiar with the asp.net model to learn about how the
code behind model works, and how the model for putting all your code
directly into the .aspx works.

"Cyril Kearney" <cy***********@hotmail.com> wrote in message
news:37**************************@posting.google.c om...
I am trying to learn C# over the internet. My ISP only allows .aspx
files. All .cs files are rejected.

The tutorials on the Internet are aimed at people able to run .cs
files from the command line. I can't do this.

Here's an almost universal first example.

using System;
class HelloWorld
{
public static void Main()
{
Console.WriteLine("Hello World !");
}
}

I've modified it to this and saved it as test.aspx but it doesn't run

<%@ Page language="c#" Debug="true"%>

<script Language="c#" runat="server">
using System;
class HelloWorld
{
public static void Main()
{
Response.Write("Hello World !");
}
}
</script>

I can't figure out what I'm doing wrong. Shouldn't all C# programs be
able to run in an .aspx file using Response.Write instead of
Console.WriteLine?

Thanks in advance for any help.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Philip Ronan | last post by:
OK, here's my 2p worth: === Q. Why am I getting the error message 'Headers already sent'? A. PHP produces this error message when you try to set a header for a web page after you have already...
5
by: Paul H | last post by:
How do you folks get a reliable and complete brief of what is required before development starts? I am forever going back to a client once a project has started saying "Hang on, now that I've...
84
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: ...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
4
by: goldbond_8 | last post by:
I am looking to learn VB.net. I have been programming in VB6 for about 3 years but have not done much Object Oriented Programming. I know VB.Net is much different from VB6, so my question is,...
6
by: Jack Duijf | last post by:
Hello, I am looking for a person in The Netherlands that is willing to help me getting started with Vb.net. Please send a message to jack@aicn.nl if you can help me getting started with the...
9
by: David Sulc | last post by:
Hi ! I've looked all over (internet, books, etc.) and I haven't found a very good ressource to get started with wxPython (yes, I've been through their tutorial). What I would basically like...
19
by: sasan3 | last post by:
Every thread I start goes out on a tangent simply because some of you people are not reading my posts carefully: Here is the phrase I am proposing for inclusion in the FAQ: "to existing...
1
by: =?Utf-8?B?Q29kZVNsaW5nZXI=?= | last post by:
I plan to build my own 2008 Server/Hyper-V system and will not be using one of the tested Dell or HP systems from the release notes and could use some pointers as to my assumnptions and answers to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.