我正在尝试使用以下命令让我的第一个 ASP.NET 网页在 Windows 上运行 单核细胞增多症 和 XSP Web 服务器。

我正在关注这个小伙子 例子. 。这 第一部分 他的示例与最新版本的 mono 配合得很好。但是 Web 部件似乎因以下错误而崩溃

'{路径名} index.aspx.cs'不是有效的虚拟路径。

这是完整的堆栈跟踪:

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] 

我想知道是否有人知道这个错误是什么意思。我想我正在寻找一位尝试过 Windows 版本的单声道专家。

有帮助吗?

解决方案 3

嘿,我不知道如何让“代码隐藏”的东西工作,但我找到了一个我很满意的解决方法。我想我应该将其发布在这里是为了其他人的利益。基本上,您将代码移到主页中,只需使用

XSD 命令且无参数。

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

其他提示

您可以粘贴用于启动xsp的命令行吗?如果您只是运行单个Web应用程序,则不需要这样的东西,并且可能是问题的根源:

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

只需cd到ASPExample目录并运行没有参数的xsp。

我正在使用的命令是:

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

我尝试运行没有参数的XSP,我得到以下输出:

  

xsp2收听地址:0.0.0.0   根目录:   C:\ Projects \ Mono \ ASPExample Listening   在港口:8080(非安全)命中返回   停止服务器。

当我尝试浏览

上的项目时

http:// localhost:8080

我获得与之前相同的输出。抱怨cs文件不是有效的虚拟路径。

我认为ASPX页面的src属性是问题所在。也许它已在新版Mono中更新过。我要调查一下。

感谢您的回复BTW。

戴夫

您是否尝试过运行xsp2而不是xsp?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top