views:

994

answers:

4

Hey,

I'm attempting to get my first ASP.NET web page working on windows using Mono and the XSP web server.

I'm following this chaps example. The first part of his example works very well with the latest version of mono. however the web part seems to fall over with the following error

'{Path Name}\Index.aspx.cs' is not a valid virtual path.

Here's the full Stack Trace:

System.Web.HttpException: 'C:\Projects\Mono\ASPExample\simpleapp\index.aspx.cs' is not a valid virtual path.  
   at System.Web.HttpRequest.MapPath (System.String virtualPath, System.String baseVirtualDir, Boolean allowCrossAppMapping) [0x00000]   
   at System.Web.HttpRequest.MapPath (System.String virtualPath) [0x00000]   
   at System.Web.Compilation.BuildManager.AddToCache (System.String virtualPath, System.Web.Compilation.BuildProvider bp) [0x00000]   
   at System.Web.Compilation.BuildManager.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000]   
   at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000]   
   at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath (System.String virtualPath, System.Type requiredBaseType) [0x00000]   
   at System.Web.UI.PageParser.GetCompiledPageInstance (System.String virtualPath, System.String inputFile, System.Web.HttpContext context) [0x00000]
   at System.Web.UI.PageHandlerFactory.GetHandler (System.Web.HttpContext context, System.String requestType, System.String url, System.String path) [0x00000]
   at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url, Boolean ignoreContextHandler) [0x00000]
   at System.Web.HttpApplication.GetHandler (System.Web.HttpContext context, System.String url) [0x00000]
   at System.Web.HttpApplication+<Pipeline>c__Iterator5.MoveNext () [0x00000]

I was wondering if anyone knew what this error meant. I guess i'm looking for a mono expert, who's tried out the windows version.

+1  A: 

Can you paste the command line you are using to start xsp? If you are just running a single webapp something like this isn't really needed, and could be the source of the problem:

xsp --applications /SimpleWebApp:C:\Projects\Mono\ASPExample\

just cd to the ASPExample directory and run xsp with no parameters.

Jacksonh
A: 

Hey,

The command i was using was this:

@echo off
call C:\PROGRA~1\MONO-2~1.1\bin\setmonopath.bat
xsp --root . --port 8088 --applications /:.

I tried just running XSP with no parameters and i get the following output:

xsp2 Listening on address: 0.0.0.0 Root directory: C:\Projects\Mono\ASPExample Listening on port: 8080 (non-secure) Hit Return to stop the server.

When i try to browse to the project on

http://localhost:8080

I get the same output as before I.e. moaning that the cs file isn't a valid virtual path.

I'm thinking that the src attribute of the ASPX page is the problem. Perhaps it's been updated in the new version of Mono. I'm going to look into that.

Thanks for your reply BTW.

Dave

CraftyFella
A: 

Hey i don't know how to get the "code behind" stuff working but i've found a workaround that i'm happy with. I thought i'd post it up here for the benefit of others. Basically you move the code behind into the main page and it works great just by using the

XSD command and no parameters.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>Code behind Arrrrrrrrrrgh</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <script runat="server">
    private void Page_Load(Object sender, EventArgs e)
    {
       DisplayServerDetails();
       DisplayRequestDetails();

    }

    private void DisplayServerDetails()
      {
        serverName.Text = Environment.MachineName;
        operatingSystem.Text = Environment.OSVersion.Platform.ToString();
        operatingSystemVersion.Text = Environment.OSVersion.Version.ToString();
      }

      private void DisplayRequestDetails()
      {
         requestedPage.Text = Request.Url.AbsolutePath;
         requestIP.Text = Request.UserHostAddress;
         requestUA.Text = Request.UserAgent;
      }

    </script>

  </head>

  <body>
    <form method="post" runat="server">
         <table width="450px" border="1px">
            <tr>
               <td colspan="2"><strong>Server Details</strong></td>
            </tr>
            <tr>
               <td>Server Name:</td>
               <td>
                  <asp:Label id="serverName" runat="server"></asp:Label></td>
            </tr>
            <tr>
               <td>Operating System:</td>
               <td>
                  <asp:Label id="operatingSystem" runat="server"></asp:Label>
               </td>
            </tr>
            <tr>
               <td>Operating System Version:</td>
               <td>
                  <asp:Label id="operatingSystemVersion" runat="server">
                  </asp:Label>
               </td>
            </tr>
         </table>
         <br>
         <table width="450px" border="1px">
            <tr>
               <td colspan="2"><strong>Request Details</strong></td>
            </tr>
            <tr>
               <td>Page Requested:</td>
               <td>
                  <asp:Label id="requestedPage" runat="server"></asp:Label>
               </td>
            </tr>
            <tr>
               <td>Request From:</td>
               <td>
                  <asp:Label id="requestIP" runat="server"></asp:Label>
               </td>
            </tr>
            <tr>
               <td>User Agent:</td>
               <td>
                  <asp:Label id="requestUA" runat="server"></asp:Label>
               </td>
            </tr>
         </table>
      </form>
  </body>
CraftyFella
A: 

Have you tried running xsp2 rather than xsp?

Kris Erickson