http://www.c-sharpcenter.com/asp.net/asprfrommcons.aspmaybe help

解决方案 »

  1.   

    一看就没学好ASP,一样的,都用Response.Write
      

  2.   

    to  xanewong111(冰吻):
    Response.Write就写到客户端的输出了吧。
    我想在服务器的控制台上输出信息。
      

  3.   

    java启动的时候有个console,可是.net么有的呀,怎么输出啊。或者你在一开始自己启动一个console,去读文件,你把所有针对console的输出弄到文件里去
      

  4.   

    可以直接写LOG日志嘛,
    我的示例
    public class DefaultLogger
    {
    private static string path = @"D:\MyDebug.txt";

    public static string Path {
     get{return path;}
              set{path = value;}
    }

     public static void debug( string txtValue)
             {
              string AccessTime=DateTime.Now.ToString();
             if (!File.Exists(Path)) 
             {
                // Create a file to write to.
                 using (StreamWriter sw = File.CreateText(Path)) 
                 {


    sw.WriteLine("AccessTime"+AccessTime);
                     sw.WriteLine(txtValue);
                    
                 }    
             }
             else
             {
             using (StreamWriter sw = File.AppendText(Path)) 
                 {

    sw.WriteLine("AccessTime"+AccessTime);
                     sw.WriteLine(txtValue);
                    
                 }    
            
             }
             }


    }编译成DLL控件,调用DefaultLogger.debug("")就可以了
      

  5.   

    我也写了一个AddLog的类,但是输出到Console是为了在写Log出错的时候发警报的......继续求解
      

  6.   

    using System;
    using System.Diagnostics;TextWriterTraceListener myWriter = new
     TextWriterTraceListener(System.Console.Out);
     Debug.Listeners.Add(myWriter);
    Debug.Write("My error message. ");
      

  7.   

    主要是老兄没考虑到线程问题,万一不行你可以考虑用log4net来管理写日志。