Reputation:
Is there a way to execute a full ASPX source file where the page source is from a string/database/resource and not a file on the file system? It's straightfoward to render dynamic content/images/etc using HTTP Handlers and Modules and writing to the Response, but there doesn't seem to be a way to execute/compile ASPX source without a file on the file system. For example:
The goal is to be able to execute a string source like the following from a Handler/Module/ViewEngine and not require a file on the file system (but get the source from another location):
<%@ 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>
(NOTE: The sample above is just a simple example, but shows using server controls, data binding syntax, a master page and possible user control declarations in page directives, etc...)
I hope this makes sense!
Upvotes: 3
Views: 380
Reputation: 20800
I knew that SharePoint Server used to keep the ASPX pages in the database and not on the file system. Details, however, I do not hold.
Upvotes: 0
Reputation: 52198
Update: Check the post by korchev using virtualpathprovider, which is more suited for this scenario.
Can you use a dummy file with a place holder literal control and replace the literal control with the actual source?
These might not be useful but posting couple of links I found:
Loading an ASP.NET Page Class dynamically in an HttpHandler
How To: Dynamically Load A Page For Processing
Upvotes: 1
Reputation: 30671
Perhaps you need a virtual path provider. It allows you to store the ASPX and codebehind in different media - RDBMS, xml file etc.
Upvotes: 5