openkava

专注物流系统,企业信息化,进出口业务,会展,电子商务 目标:CIO 架构师
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

c# aspx 动态编译文件模板

Posted on 2008-06-26 12:11  openkava  阅读(503)  评论(0)    收藏  举报
模板一:
<%@ 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>