This is not a valid location for a breakpoint

后端 未结 4 2236
梦毁少年i
梦毁少年i 2021-02-13 03:44

I am trying to put a breakpoint on below mentioned page in my ASP.Net MVC 2 application\'s .ascx or .aspx files in Visual Studio 2010. But it won\'t let me, it shows:

4条回答
  •  甜味超标
    2021-02-13 04:19

    Looking at the content of the <% %> code block in your screenshot shows that the syntax is not highlighted. Usually this means that VS has not recognised that the block contains server side C# code.

    It works for Javascript because VS can recognise that as client side script and break on it.

    Fix the syntax highlighting and you'll be able to break on it too.

    Typically this happens because VS has a tough job switching between HTML editing (with visual preview, of a sort) and C# code and occasionally gets it wrong.

    The commonest cause of this is a missing Language directive at the top of the .aspx or .ascx file:

    <%@ Page Language="C#" ...
    

    Or

    <%@ Control Language="C#" ...
    

    You can also try an explicit code block, something like:

    
    
                                     
                  
提交回复
热议问题