none
Newbie Debugging Question: I need to see the code! RRS feed

  • Question

  • Dealing with applications written in this horrible "MVC" setup.
    They were written by a developer that has left the company.

    Actually have the same problem with two apps, lets concentrate on the "SiteVisitorRegister".
    Trying to work out one of the "Views" (or possibly a "Partial View") doesn't work correctly. It's displaying data for some Sites and not others.

    I'm trying to debug, which as usual with MVC C#Sharp is a total nightmare, with bits of code and god knows what hidden all over the place (rant over).

    So I've set this up in my Laptop using Visual Studio 2017 "Community Edition".
    At the moment for this one, I can press "Debug"; having added Breakpoints in the places I've had to guess might be relevant.

    What happens when you do that? It simply opens the website, but it doesn't actually debug it. For example, I can't see what code is running - it simply opens the relevant page, without allowing me to see what is running.

    Any ideas? What is the point of "Debugging" something if it doesn't show you what code is running?

    Friday, July 5, 2019 12:32 PM

All replies

  • Hi SSIS_Newbie_1234,

    Sorry for delay in reply.

    When you debug(aka open) web site, please open Debug/Aattach to Process. Then select the iisexpress.exe in the process list, attach it. Then you could debug with breakpoint.

    If there is any update information, please feel free to contact us.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com


    Monday, July 8, 2019 6:16 AM
  • Hi,

    I tried that but iisexpress.exe is not in the list.

    Tuesday, July 9, 2019 1:54 PM
  • Hi SSIS_Newbie_1234,

    Thank you for reply.

    Please open Debug/Attach to process during debugging, which is like the below picture:

    If it is still not here, please open visual studio installer to repair visual studio.

    Best Regards,

    Dylan 


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, July 10, 2019 7:58 AM
  • Hi,
    I ran C:\Program Files (x86)\IIS Express\iisexpress.exe
    Since that's what everyone is talking about.
    This gives a command window saying:
    Starting IIS Express ...
    Failed to register URL "http://localhost:8080/" for site "Website1" application "/". Error description: Access is denied. (0X80070005).
    IIS Express is running.
    Enter 'Q' to stop IIS Express

    Went back into Visual Studio, found the website I want to debug, and pressed debug.
    FYI: I need to debug compiled code, so in Debug Start options I've put the website I need: http://localhost/genieweb

    I can now attach IIS Express - iisexpress.exe ID 10696 Title: IISExpress - WebSite 1

    But it still doesn't debug the code I want. I've no idea what "WebSite 1" is, it doesn't seem to appear in Internet Information Services Manager.
    But if we could somehow change from Website 1 at: http://localhost:8080/
    To the actual website I want to debug: http://localhost/genieweb

    Then maybe that would work? Any ideas? Not keen on a re-install/repair.Here should be a screenshot of my "Attach to Process" Window.

    Wednesday, July 10, 2019 8:33 AM
  • Hi SSIS_Newbie_123,

    Thank you for reply.

    According to your description, did you want to debug your asp.net project line by line? If so, I'm afraid the answer is negative. As far as I know, the debugger doesn't support line-by-line debugging currently. But you could debug the application with breakpoints.

    please refer more: Debug ASP.NET or ASP.NET Core apps in Visual Studio

    If I misunderstand it, please feel free to contact us.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, July 11, 2019 9:06 AM
  • I don't have the "web" tab mentioned in the example. Possible due to using VS 2010?

    I can see some of the code, I guessed where to put breakpoints to see exactly what is happening.
    There must be a way to debug the code; I've always managed in the past.
    I've had to go this way because other errors (I think due to trying to debug uncompiled code ? are happening otherwise)
    I've attached my debug settings and breakpoints.

    I can't really accept there is no way to debug the code - if so, then I need to explain to the business that we can no longer support there website.

    A screenshot showing debug settingsImage showing some breakpoints I set.

    Thursday, July 11, 2019 11:04 AM
  • A project with an output type of class library cannot be debugged directly is the error I get if I leave out the: http://localhost/genieweb
    Thursday, July 11, 2019 11:06 AM
  • Such error should just say, we decided to make things hard for you, knowing its code for a website, we made it so you can't debug it.
    Thursday, July 11, 2019 11:07 AM
  • Hi SSIS_Newbie_1234,

    Thank you for reply.

    Based on your description, is the type of the project Console app or dll for MVC? When you do corresponding request on MVC, could it break on the breakpoint?

    If not, please try to refer the below suggestions:

    --If the project is console app, we suggest you could set the output type to console application and set  Start Action to start project to debug.

    --If the project is dll, we suggest you could create a new console app to call the method or input values to the project, then debug the app to check if the dll could work normally.

    And if it is not them, please share a sample, and we would create a MVC sample to test it.

    Look forward to your reply.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, July 12, 2019 5:06 AM
  • Based on your description, is the type of the project Console app or dll for MVC?

    >>As I understand it it is a MVC Website built in C#.NET.
    >>Unlike other such websites I support, this one seems to need a "build" rather than just allowing you >>to debug directly in Visual Studio.

    When you do corresponding request on MVC, could it break on the breakpoint?
    >>I don't really understand the question? I think what you are describing is what I need to happen?
    >>e.g. pressing Debug in Visual Studio allows me to debug it rather than for example, give the error >>message I mentioned above?

    --If the project is dll, we suggest you could create a new console app to call the method or input values to the project, then debug the app to check if the dll could work normally.
    >>I will consider this, not quite sure how to create such a console app but it seems like a reasonable >>suggestion.

    Monday, July 15, 2019 8:48 AM
  • --If the project is dll, we suggest you could create a new console app to call the method or input values to the project, then debug the app to check if the dll could work normally.

    How to call the Web MVC Project from a Console Application?

    (What code to put in?)

    Monday, July 15, 2019 2:22 PM
  • Hi SSIS_Bewbie_1234,

    Sorry for delay in reply.

    As your image shows, the project should be the class library , the web site(http://localhost/genieweb) should call the library, when you send related request by web site, it could get/post the related information from the library. 

    So please set the library project with "start the browser with URL: ...", then have a try to set the breakponit into the GET/POST properties. And then execute corresponding request in web site, to check whether it would break at the specified location which is in library project.

    If possible, could you provide a sample using onedrive? we will follow it to create a similar sample to analysis this situation.

    Look forward to your reply.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Wednesday, July 17, 2019 5:52 AM
  • Understood some of that, so the website locally was pointing to:C:\inetpub\wwwroot\GenieWeb\WebApplication\DEV

    I changed that to:
    C:\Users\myuserid\Documents\Visual Studio 2010\ProjectGenieNew\GenieWeb
    * - this is were GenieWeb is compiling to.
    Eventually got the changeover working (had to manually copy some dll's across)
    Set some breakpoints at random places in the code.
    Did a build.

    I'm back to where I was; website is running locally but still cannot be debugged.
    I'm happy to provide any files you like over onedrive if you can describe how; I have both a personal and a work one, or I can paste it somewhere?

    Wednesday, July 17, 2019 4:10 PM
  • Hi SSIS_Newbie_1234,

    Thank you for reply.

    Since the project belongs to your company, we recommend you could use the work one. OR you could also upload to github.

    Note: please make sure the project could be shared to public version, in case of important information leakage.

    Look forward to your reply.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Thursday, July 18, 2019 8:42 AM
  • Not too keen to share and I don't really know how anyway.

    Just as a test, I created a blank "ASP.Net MVC 4 Web Application" Solution\Application.
    That still has a "type" of Class Library, with a blank website, butyou are able to debug it correctly. For the project that you can't debug, the settings shown in the attached are not there.

    e.g. the whole of this "WEB" tab is "Not Avaliable" - it just isn't in the list to select from.

    So the error message is even more misleading - you can clearly debug Class Library's. But only sometimes and not others!

    Thursday, July 18, 2019 12:47 PM
  • Hi SSIS_Newbie_1234,

    Thank you for reply.

    I could also debug a controller with MVC with breakpoint.

    As your previous image, the properties page is like the class library, so that I misunderstand it :

    And as your previous reply, the vs2010 seems to be old. And as far as I know, IDE doesn't support line-by-line to debug it currently, we suggest you continue to use VS2017 or newer version to debug it with breakpoint.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, July 19, 2019 7:45 AM
  • Hi,

    I can "line by line" debug my test project which is a "class library" but MVC Web Application template, even in Visual Studio 2010.

    The code unfortunately was written in old version and I'm not sure what affect attempting to upgrade it will have.

    Friday, July 19, 2019 10:43 AM
  • Hi SSIS_Newbie_1234,

    Sorry for delay in reply.

    We recommend you could back up the initial project, then do a upgrade for it. If there are some issues about debugger, please feel free to contact us.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Monday, July 22, 2019 6:51 AM