代码如下
控制台类型程序using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.IO;namespace ConsoleApplication1
{
    class Program : System.Web.UI.Page
    {
        public static string geta(string key)
        {
            StreamWriter sw = new StreamWriter("a.txt");
            HttpResponse response = new HttpResponse(sw);
            HttpRequest request = new HttpRequest("b.txt", "http://localhost:1365/WebSite3/Default.aspx", "");
            HttpApplication ha = new HttpApplication();
            HttpContext hc = new HttpContext(request, response);
            //hc.Application.Add("dfg", "fffff");
            
            
            return (hc.Application[key] == null).ToString();
        }        static void Main(string[] args)
        {
            Console.Write(geta("jack"));
            Console.ReadKey();
        }
    }
}

解决方案 »

  1.   

    你这是控制台应用程序,Application必须在web上下文中才能取得
      

  2.   

    在 控制台 程序 里 取得 Application 是 我们 公司 给 我 的任务
    急 啊!
    各位高手多帮帮忙
      

  3.   

    你这是控制台应用程序,Application必须在web上下文中才能取得
      

  4.   

    你用hashtable吧,你那个applicaton根本没有上下文,当然是空的了。
      

  5.   

    你这是控制台应用程序,Application必须在web上下文中才能取得   
      

  6.   

    有没有什么办法在控制台程序中获得Application 呢
    最好 不要 通过 网页