将asp或asp.net页面(同时包括页面和代码)保存为Txt文件或保存到数据库中,
然后编程从数据库中读取该数据,并发送给界面。如果单纯是HTML,没有代码,则直接用Response.Write(data)就可以了,但是如果有代码,这样输出后代码被看成是普通文本,并不执行,请问如何才能使代码执行呢?
解决方案 »
- jquery两次请求的问题。
- 数据库的设计,有点不懂,就是问问,高手别喷
- gridview如何转换成静态页面
- GridView的行數問題
- ASP.NET的自定义控件有的设计页面怎么看不到效果?
- 如何用名称而不是索引访问SqlParameter[] 数组?
- 超简单问题,小妹没分,先谢过了
- 大大们进来吧,数据显示折叠问题
- 为什么很多精华贴看不了???
- btnSave.Attributes["onclick"]=""的问题,可以返回对话框而不“执行服务端代码”吗???
- 页面嵌套iframe的子页,可以点击iframe里面的链接,整个页面都打开新的页面,包括iframe外面的页也变化.
- 求电力行业物资编码标准,主要是材料编码!
[Visual Basic]
<ComVisible(True)>
NotInheritable Public Class WebClient
Inherits Component
[C#]
[ComVisible(true)]
public sealed class WebClient : Component
[C++]
[ComVisible(true)]
public __gc __sealed class WebClient : public Component
线程安全
此类型的所有公共静态(Visual Basic 中为 Shared)成员对多线程操作而言都是安全的。但不保证任何实例成员是线程安全的。备注
WebClient 类提供向 URI 标识的任何本地、Intranet 或 Internet 资源发送数据以及从这些资源接收数据的公共方法。WebClient 类使用 WebRequest 类提供对 Internet 资源的访问。WebClient 实例可以通过任何已向 WebRequest.RegisterPrefix 方法注册的 WebRequest 子代访问数据。注意 默认情况下,.NET 框架支持以 http:、https: 和 file: 方案标识符开头的 URI。
WebClient 类提供四种将数据上载到资源的方法: OpenWrite 返回一个用于将数据发送到资源的 Stream。
UploadData 将字节数组发送到资源并返回包含任何响应的字节数组。
UploadFile 将本地文件发送到资源并返回包含任何响应的字节数组。
UploadValues 将 NameValueCollection 发送到资源并返回包含任何响应的字节数组。
WebClient 类还提供三种从资源下载数据的方法: DownloadData 从资源下载数据并返回字节数组。
DownloadFile 从资源将数据下载到本地文件。
OpenRead 从资源以 Stream 的形式返回数据。 下面的示例创建一个 WebClient 实例,然后使用该实例从服务器下载数据并将其显示在系统控制台上、从服务器下载数据并将其写入文件、以及将窗体值上载到服务器并接收响应。[Visual Basic]
Public Shared Sub Main()
Try
Dim client As New WebClient()
Dim pageData As [Byte]() = client.DownloadData("http://www.contoso.com")
Dim pageHtml As String = Encoding.ASCII.GetString(pageData) ' Download the data to a buffer.
Console.WriteLine(pageHtml)
' Download the data to a file.
client.DownloadFile("http://www.contoso.com", "page.htm")
' Upload some form post values.
dim form as New NameValueCollection()
form.Add("MyName", "MyValue") ' Note that you need to replace "http://localhost/somefile.aspx" with the name of
' a file that is available to your computer.
Dim responseData As [Byte]() = client.UploadValues("http://www.contoso.com/form.aspx", form)
Console.WriteLine(Encoding.ASCII.GetString(responseData))
Catch webEx As WebException
if webEx.Status = WebExceptionStatus.ConnectFailure then
Console.WriteLine("Are you behind a firewall? If so, go through the proxy server.")
end if
Console.Write(webEx.ToString())
End Try
End Sub 'Main
[C#]
try {
// Download the data to a buffer.
WebClient client = new WebClient(); Byte[] pageData = client.DownloadData("http://www.contoso.com");
string pageHtml = Encoding.ASCII.GetString(pageData);
Console.WriteLine(pageHtml); // Download the data to a file.
client.DownloadFile("http://www.contoso.com", "page.htm"); // Upload some form post values.
NameValueCollection form = new NameValueCollection();
form.Add("MyName", "MyValue");
Byte[] responseData = client.UploadValues("http://www.contoso.com/form.aspx", form); }
catch (WebException webEx) {
Console.WriteLine(webEx.ToString());
if(webEx.Status == WebExceptionStatus.ConnectFailure) {
Console.WriteLine("Are you behind a firewall? If so, go through the proxy server.");
}
继续呀,急