Max*_*mov 14 asp.net asp.net-mvc
我System.Console.WriteLine("How can I see this debugging information in a browser");
在asp.net mvc4项目的内部模型中写道.如何在浏览器中或至少在visual studio中看到这个小小的字符串.在visual studio的输出窗口中找不到它.也许我需要从nuget安装一些插件...
Sto*_*now 38
Console.WriteLine(...)
将不会显示.如果您绝对需要在调试器中查看输出,则必须使用
System.Diagnostics.Debug.WriteLine("This will be displayed in output window");
Run Code Online (Sandbox Code Playgroud)
并在" 输出"窗口中查看它.您可以通过以下方式打开输出窗口Debug -> Window -> Output
:
以下是一个示例:
如需进一步阅读,请查看此SO帖子.
Mic*_*r3D 21
您可以使用以下类从C#代码写入Javascript控制台
using System.Web;
public static class Javascript
{
static string scriptTag = "<script type=\"\" language=\"\">{0}</script>";
public static void ConsoleLog(string message)
{
string function = "console.log('{0}');";
string log = string.Format(GenerateCodeFromFunction(function), message);
HttpContext.Current.Response.Write(log);
}
public static void Alert(string message)
{
string function = "alert('{0}');";
string log = string.Format(GenerateCodeFromFunction(function), message);
HttpContext.Current.Response.Write(log);
}
static string GenerateCodeFromFunction(string function)
{
return string.Format(scriptTag, function);
}
}
Run Code Online (Sandbox Code Playgroud)
就像它的JS版本一样,它实际上将你的消息转换为JS并将其注入页面.
归档时间: |
|
查看次数: |
62800 次 |
最近记录: |