Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 调试实时ASP.net网站_C#_Asp.net_.net_Debugging - Fatal编程技术网

C# 调试实时ASP.net网站

C# 调试实时ASP.net网站,c#,asp.net,.net,debugging,C#,Asp.net,.net,Debugging,我有一个C#ASP.net网站。在本地,我可以在调试中运行它,并逐步查看代码,以了解为什么事情不起作用,但当它托管在我的live站点上时,我无法做到这一点 调试我的网站的最佳方式是什么 我应该添加首秀/输出/跟踪语句吗 如果是的话,我该如何查看这些的输出?我可以在Chrome-->开发者工具中查看它们吗 例如,现在我可以在我的网站上注册一个用户,这样我就知道数据库连接是好的,但是我不能登录一个注册用户,我想知道为什么 谢谢您可以在应用程序上添加跟踪和调试日志。为方便起见,您可以使用以下日志框架

我有一个C#ASP.net网站。在本地,我可以在调试中运行它,并逐步查看代码,以了解为什么事情不起作用,但当它托管在我的live站点上时,我无法做到这一点

调试我的网站的最佳方式是什么

我应该添加首秀/输出/跟踪语句吗

如果是的话,我该如何查看这些的输出?我可以在Chrome-->开发者工具中查看它们吗

例如,现在我可以在我的网站上注册一个用户,这样我就知道数据库连接是好的,但是我不能登录一个注册用户,我想知道为什么


谢谢

您可以在应用程序上添加跟踪和调试日志。为方便起见,您可以使用以下日志框架
实际上,您可以编写自己的日志机制,在其中创建日志类和其中的一些函数,例如

 public class Log
    {

        internal static bool RecordLog(string strSource, string strMethodName, string strStatement)//additional params you think appropriate for your logs
        {


                List<string> lstInfo = new List<string>();

                string strProductName = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location.ToString()).ProductName.ToString();
                string strProductVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location.ToString()).ProductVersion.ToString();

                try
                {
                    strProductName = FileVersionInfo.GetVersionInfo(Assembly.GetCallingAssembly().Location.ToString()).ProductName.ToString();
                    strProductVersion = FileVersionInfo.GetVersionInfo(Assembly.GetCallingAssembly().Location.ToString()).ProductVersion.ToString();
                }
                catch
                {
                }

                try
                {
                    lstInfo.Add("** Date=" + DateTime.Now.ToString("d MMM yy, H:mm:ss") + ", " + strProductName + " v" + strProductVersion);
                    lstInfo.Add("Source=" + strSource + ", Server=" + strServerIP + ""); //add more info in list as per rquirement                  

                    bool flag = blnWriteLog("LogFilename",  lstInfo);
                }
                catch (Exception objEx)
                {
                 //exception handling 
                }

            return true;
        }

        private static bool blnWriteLog(string strProductName,  List<string> lstInfo)
        {
            string strPath = strGetLogFileName(strProductName);
            using StreamReader write in the log file received 

            return true;
        }

        private static string strGetLogFileName(string strFilePrefix)
        {
            //logic to check your file name, if it exists return name else create one 

            return strFile;

        }
    }

注意:以上只是一种建议的方法,还有许多其他有效的方法

您可以使用内置的Microsoft Intellitrace功能从生成的Intellitrace日志中单步执行代码。此链接说明如何实现以下目标:

“如果您使用Microsoft Monitoring Agent控制IntelliTrace, 您还需要在上设置应用程序性能监视 您的web服务器。这将在应用程序运行时记录诊断事件 并将事件保存到IntelliTrace日志文件中 Visual Studio Enterprise中的事件(但不是专业或 社区版),转到发生事件的代码,查看 该时间点的记录值,并向前移动或 在找到并修复 如果出现问题,请重复该周期以构建、发布和监视您的发布 因此,您可以更早更快地解决未来的潜在问题。”


Trace
和DebugView是一个很好的日志框架中的朋友。我如何/在何处查看实时网站上的这些输出?调试或浏览实时网站的代码是否有意义?是的,因为我想知道它为什么不起作用。它在我的PC上本地运行,但在运行时不起作用。如果可以的话,将应用程序部署到一个新的虚拟机上,最好是一个与实时环境类似的虚拟机。您可能会发现在部署过程中出错或缺少环境是很愚蠢的。通过这种方式,您可以部署调试代码,并在需要时对其进行远程调试。我在实时网站上的何处查看跟踪和调试日志?您可以配置n-log和serilog在何处写入日志。看见
Log.RecordLog()// Values as per your code and requirement