C# Server.Transfer传值方式

  1. //页面CreateFilePath.aspx.cs   
  2. public  partial  class  CreateFilePath : System.Web.UI.Page  
  3. {  
  4.     //要传给Default.aspx页面的值   
  5.     public   string  Name  
  6.     {  
  7.         get  {  return   "ffff" ; }  
  8.     }  
  9.   
  10.     protected   void  Page_Load( object  sender, EventArgs e)  
  11.     {  
  12.         //终止当前页面,使用指定路径执行一个新页面   
  13.         Server.Transfer("Default.aspx" );  
  14.     }  
  15. }  
  16.   
  17. //页面Default.aspx.cs   
  18. public  partial  class  _Default : System.Web.UI.Page   
  19. {     
  20.     protected   void  Page_Load( object  sender, EventArgs e)  
  21.     {  
  22.         //获取负责处理次HTTP请求的对象,转化为CreateFilePath类实例   
  23.         CreateFilePath d = Context.Handler as  CreateFilePath;  
  24.   
  25.         //获取值   
  26.         Response.Write(d.Name);  
  27.     }  

原文地址:https://www.cnblogs.com/hanwest/p/2881894.html