我想知道如何从我的asp.net mvc 4控制器向Internet Explorer调试控制台编写调试消息。我在下面做了但是没有用。当我在默认网站上发布我的应用程序并启动它时,没有任何消息打印到Internet Explorer控制台。
try
{
}
catch (Exception ex)
{
Console.WriteLine("Exception raised from the controller: " + ex.Message);
}
有什么想法吗?
答案 0 :(得分:1)
Console.Write*
是您的本地输出窗口,而不是IE。所以,如果你想写IE(假设console.*
是你的意思和支持......)你需要这样的东西:
@{
Message = /* ??? source ??? */;
}
<script>console.log(@Message)</script>
但是,这意味着现在需要将ex.Message
传递给视图(尽管视图模型,ViewBag
等)。
然而,更好的解决方案可能是查看Elmah(用于记录和跟踪)或Glimpse(给你&#34;客户端&#34;调试信息)。