Domanda

Sto tentando di far funzionare la mia prima pagina Web ASP.NET su Windows utilizzando Mono e il server Web XSP.

Sto seguendo questi chap esempio . La prima parte del suo esempio funziona molto bene con l'ultima versione di mono. tuttavia la web part sembra cadere con il seguente errore

  

'{Nome percorso} \ Index.aspx.cs' non è un   percorso virtuale valido.

Ecco la traccia stack completa:

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] 

Mi chiedevo se qualcuno sapesse cosa significava questo errore. Immagino che sto cercando un esperto mono, che ha provato la versione di Windows.

È stato utile?

Soluzione 3

Ehi, non so come ottenere il codice " dietro " roba funzionante ma ho trovato una soluzione di cui sono contento. Ho pensato di pubblicarlo qui a beneficio di altri. Fondamentalmente si sposta il codice nella pagina principale e funziona alla grande semplicemente usando

Comando XSD e nessun parametro.

<%@ 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">
<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>

Altri suggerimenti

Puoi incollare la riga di comando che stai usando per avviare xsp? Se stai semplicemente eseguendo una singola webapp, qualcosa del genere non è davvero necessario e potrebbe essere la fonte del problema:

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

basta cd nella directory ASPExample ed eseguire xsp senza parametri.

Il comando che stavo usando era questo:

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

Ho provato a eseguire XSP senza parametri e ottengo il seguente output:

  

xsp2 Ascolto sull'indirizzo: 0.0.0.0   Root directory:   C: \ Projects \ Mono \ ASPExample Listening   sulla porta: 8080 (non sicuro) Hit Return   per arrestare il server.

Quando provo a cercare il progetto su

http: // localhost: 8080

Ottengo lo stesso output di prima, ad es. gemendo che il file cs non è un percorso virtuale valido.

Sto pensando che l'attributo src della pagina ASPX sia il problema. Forse è stato aggiornato nella nuova versione di Mono. Lo esaminerò.

Grazie per la risposta BTW.

Dave

Hai provato a eseguire xsp2 anziché xsp?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top