Can't break in global.asax / Application_Start

后端 未结 9 1250
名媛妹妹
名媛妹妹 2021-02-01 16:49

I got a break point on the first line of Application_Start(), but Visual Studio wont break on it.

Visual Studio have attached itself to the IIS working proc

9条回答
  •  青春惊慌失措
    2021-02-01 17:46

    If using IISEXPRESS is not an option, as @David Perlman mentions, I would go for a Logger. Log4Net or NLog are both good. It's good to have a logger in the longrun, for instance in production environments.

    namespace DataService
    {
        using NLog;
        public class Global : System.Web.HttpApplication
        {
            private Logger log; 
            protected void Application_Start(object sender, EventArgs e)
            {
                LogManager.LoadConfiguration("nlog.config");
                log = LogManager.GetCurrentClassLogger(); 
                log.Error($"Read this line in the log specified in nlog.config");
            }
    

提交回复
热议问题