Code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Reflection" %>
<%
Response.ContentType = "Text/Plain";
Response.Write("HELLO WORLD!\n\n");
Response.Write("ASP.NET version is " + System.Environment.Version.ToString());
Response.Write("\n\n");
Type monoRuntimeType;
MethodInfo getDisplayNameMethod;
if ((monoRuntimeType = typeof(object).Assembly.GetType("Mono.Runtime")) != null && (getDisplayNameMethod = monoRuntimeType.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly | BindingFlags.ExactBinding, null, Type.EmptyTypes, null)) != null)
Response.Write("Mono Verson: " + (string)getDisplayNameMethod.Invoke(null, null));
else
Response.Write("Mono.Runtime.GetDisplayName not implemented(probably on windows?)");
%>
that works
http://com.x10hosting.com/test.aspx
ASP.net is run under mono on a linux server, so there are some considerations you need to keep in mind.
.net 2.0 is fully supported, have not tested 3.5 or 4, though technically those should be supported, since the mono version is 2.6
filenames are case sensitive under linux, so default.aspx.cs is not the same as Default.aspx.cs
Use forward-slash /////// when accessing stuff(IE: File.ReadAllLines("./data/SomeDirectories/MoreStuff/someData.xml"))
Otherwise your scripts should work.
[edit]
The tutorial is full of large holes.
http://com.x10hosting.com/test2.aspx
that is the fixed tutorial, and it works.
Here is a modified version of his tutorial:
Make sure to use the file names exactly as shown
Code:
<!-- this line is for C# projects -->
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HelloWorld.aspx.cs" Inherits="HelloWorld" %>
Or
Code:
<!-- this line is for VB.Net projects -->
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="HelloWorld.aspx.vb" Inherits="HelloWorld" %>
And this is the rest of xhtml for both languages:
Code:
<!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>Hello World!</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Erm, Hello World!"></asp:Label>
<br /> <br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Press Me" />
</div>
</form>
</body>
</html>
That’s the html sorted. Now on to the code-behind file.
C# HelloWorld.aspx.cs:
Code:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class HelloWorld: System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Asp.Net post test worked.";
}
}
Or
VB.Net HelloWorld.aspx.vb
Code:
Partial Class HelloWorld
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Label1.Text = "ASP.Net post test Worked"
End Sub
End Class