gpt4 book ai didi

asp.net - 能否从非文件系统的源处理 ASP.NET ASPX 页面?

转载 作者:行者123 更新时间:2023-12-01 11:10:46 25 4
gpt4 key购买 nike

有没有办法在页面源来自字符串/数据库/资源​​而不是文件系统上的文件的情况下执行完整的 ASPX 源文件?使用 HTTP 处理程序和模块呈现动态内容/图像/等并写入响应是很简单的,但似乎没有一种方法可以在文件系统上没有文件的情况下执行/编译 ASPX 源代码。例如:

  • HttpContext.Current.Server.Execute() 重载需要一个文件路径
  • System.Web.Compilation.BuildManager 只能从虚拟路径创建

目标是能够从 Handler/Module/ViewEngine 执行如下字符串源,而不需要文件系统上的文件(但从另一个位置获取源):

<%@ Page language="C#" MasterPageFile="~/Shared/Site.Master" Inherits="System.Web.UI.Page" %>
<!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 id="Head1" runat="server">
<title>ListView Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>ListView Example</h3>
<asp:ListView ID="List" runat="server" DataSourceID="ProductDataSource">
<LayoutTemplate><ol><asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder></ol></LayoutTemplate>
<ItemTemplate><li><%# Eval("ProductName") %></li></ItemTemplate>
</asp:ListView>
<asp:AccessDataSource ID="ProductDataSource" runat="server"DataFile="~/App_Data/Northwind.mdb"SelectCommand="SELECT [ProductName], [QuantityPerUnit], [UnitPrice], [CategoryName] FROM [Alphabetical List of Products]"></asp:AccessDataSource>
</form>
</body>
</html>

(注意:上面的示例只是一个简单示例,但显示了使用服务器控件、数据绑定(bind)语法、母版页和页面指令中可能的用户控件声明等...)

我希望这是有道理的!

最佳答案

也许您需要一个 virtual path provider .它允许您将 ASPX 和代码隐藏存储在不同的媒体中 - RDBMS、xml 文件等。

关于asp.net - 能否从非文件系统的源处理 ASP.NET ASPX 页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/154117/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com