您的位置:首页 > 编程语言 > ASP

c# aspx 动态编译文件模板

2008-06-26 12:11 225 查看
模板一:

<%@ Import Namespace="System.Data" %>

<%@ Import Namespace="System.Data.SqlClient" %>

<html>

<body>

<script language="C#" runat="server">

Response.Write("hello");

</script>

</body>

</html>

模板二:

<%@ Page Language="C#" %>

<% @Import Namespace="System.Drawing" %>

<% @Import Namespace="System.IO" %>

<% @Import Namespace="System.Drawing.Imaging" %>

<HTML>

<HEAD>

<title>test</title>

</HEAD>

<body>

<%

StringBuilder str =new StringBuilder();

//str.Append("<html><head><title> test</title></head><body>");

str.Append(" <h1> <div> hello world !!!</div></h1>");

//str.Append("<script>alert('hello')</script>");

System.IO.DirectoryInfo d= new DirectoryInfo("c:/");//Server.MapPath(".")

System.IO.FileInfo[] f = d.GetFiles();

foreach(FileSystemInfo ff in d.GetFileSystemInfos())

{

//str.Append(ff.FullName+"-----------" + ff.Extension+ff.Name+"<br/>");

}

str.Append( Request.UserHostAddress);

str.Append(this.Request.UserAgent);

string s=this.Request.ServerVariables.ToString();

str.Append( s );

//str.Append("</body></html>");

Response.Expires = 0;

Response.ClearContent();

Response.ContentType = "text/html";

Response.Write(str.ToString());

Response.End();

%>

</body>

</HTML>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: