In PHP, one can immediately stop the execution of the script and output a variable. For instance if you want to know what’s in $myVar, you could do:
var_dump($myVar); die();
Is there anyway to immediately get the value of a variable and then kill it in VB.NET?
I’m not asking for a function to include necessarily; just if there is a native function that will basically output a var immediately, without me having to add it to the controller, then the view, then publish and test. Ideally, it would just output the variable in a debugger or messagebox or something…
I am also using ASP.NET MVC 3.
Thanks.
You can use the System.Diagnostics.Trace and System.Diagnostics.Debug classes to print out information.
Stopping the execution typically occurs by either returning a relevant System.Web.Mvc.ActionResult, such as System.Web.Mvc.HttpNotFoundResult or by throwing a System.Web.HttpException with the HTTP status code which best describes the problem.
Here’s a naive example. Excuse my poor VB.
Or in C#
Note that these examples are contrived only to display the use of Debug and the return of http status codes.