一些对象或是方法,如Session, Response,Server等等,无法在类别中直接打,是因为没有在类别中引用它们的名称空间。这个名称空间(namespace):System.Web。另外它们正确的写为HttpContext.Current.Session,HttpContext.Current.Response 和HttpContext.Current.Server。

参考:  

代码
using System;
using System.Web;

/// <summary>
/// Summary description for CodeDemo
/// </summary>
public class CodeDemo
{
    
public CodeDemo()
    {
        
//
        
// TODO: Add constructor logic here
        
//
    }

    
//下面列举了几个对象与方法
    public void t()
    {
        HttpContext.Current.Session[
"mykey"= "Session content";
        HttpContext.Current.Response.Write(
"Write content.");
        HttpContext.Current.Server.MapPath(
@"z:\...\"); 
    }
}

 

相关文章:

  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
猜你喜欢
  • 2021-09-06
  • 2021-04-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2021-10-14
相关资源
相似解决方案