Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't debug Razor helper - seems IIS is not compiling with debugging symbols?

Tags:

c#

iis

razor

I am trying to debug a Razor helper function which is running locally on IIS.

Even when my helper code reads:

System.Diagnostics.Debugger.Break();

The breakpoint does not occur.

So I think it is because IIS fails to compile the function in debug mode.

I added this in web.config but it doesn't solve the issue:

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

Surely somebody else has run into this, or is just my particular laptop buggy???

Thanks! - Brian

like image 617
alpsystems.com Avatar asked Jul 08 '12 18:07

alpsystems.com


1 Answers

I figured it out, man what a wild goose chase!

I forgot the "@" symbol when calling the helper. My code looked like this:

MyHelper()

But it should look like this:

@MyHelper()

It seems in this case Razor doesn't even CALL the function, or perhaps calls it but with debug mode off, anyway I added the "@" symbol and then could trace in with the debugger again.

Seems lots of little pitfalls like that, with this Razor thingee...

Hope that helps somebody avoid losing 2 hours of their day. :-(

like image 99
alpsystems.com Avatar answered Nov 03 '22 20:11

alpsystems.com