سؤال

I need to see what values are passed to the model in my razor .cshtml view.

I try to set a breakpoint or write to Debug, but neither is working.

I am in a Debug mode, and also have

    <compilation debug="true" targetFramework="4.5" />

in web.config

How can I debug a View C# code?

enter image description here

هل كانت مفيدة؟

المحلول 2

we use to console to view information. try this in a script tag

<script type="text/javascript">
    $(document).ready(function(){
        console.log('@Model.resourceType');
    });
</script>

when the page is finished loading it will write the value of Model.resourceType to the console. for debugging script I would highly recommend looking into firefox firebug

نصائح أخرى

You can insert this line in the server-side portion of the .cshtml file:

System.Diagnostics.Debugger.Break();

When running the website, you will (or at least you should) see a system-level dialog prompting you to launch Visual Studio to debug the application (in this case, the w3wp.exe process.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top