Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The breakpoint will not currently be hit, cshtml

Tags:

c#

razor

In my Asp.Net Razor application i keep getting breakpoint will not currently be hit i have tried every single solution here the breakpoint will not currently be hit no symbols loaded with no luck. So what should i do next?

Some Information:

  1. I am using Debug mode.
  2. I am using Nancy.Templates to create a NancyFx project.
  3. The created project is set as Class Library.
  4. When i locate the module while code is running, it is loaded from GAC for some reason.
  5. I tried every possible thing, clean rebuild, creating new fresh project to test on, re-installing visual studio, even windows. Non works!
  6. I am running on Windows 8.1, using Visual Studio 2013 Ultimate, .Net 4.5.1

Here is my web.config

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5.1" />
      </system.Web>
  -->
  <system.web>
    <compilation debug="true" targetFramework="4.5.1">

    <buildProviders>
        <add extension=".cshtml" type="Nancy.ViewEngines.Razor.BuildProviders.NancyCSharpRazorBuildProvider, Nancy.ViewEngines.Razor.BuildProviders" />
        <add extension=".vbhtml" type="Nancy.ViewEngines.Razor.BuildProviders.NancyVisualBasicRazorBuildProvider, Nancy.ViewEngines.Razor.BuildProviders" />
      </buildProviders></compilation>

    <pages controlRenderingCompatibilityVersion="4.0" />
  <httpHandlers>
      <add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" />
    </httpHandlers></system.web>



<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <httpErrors existingResponse="PassThrough" />
    <handlers>
      <add name="Nancy" verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*" />
    </handlers>
  </system.webServer><appSettings>
    <add key="webPages:Enabled" value="false" />
  </appSettings><system.web.webPages.razor>
    <pages pageBaseType="Nancy.ViewEngines.Razor.NancyRazorViewBase">
      <namespaces>
        <add namespace="Nancy.ViewEngines.Razor" />
      </namespaces>
    </pages>
  </system.web.webPages.razor></configuration>

Here is the only .cshtml file i have in the solution:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title> //Here is the break point (i am able to add it) however when i start the application and browser run the breakpoint is not being hit

    <style type="text/css">

        body { 
            text-align: center;
        }

    </style>

</head>
<body>
    <img src="~/Content/nancy-logo.png" alt="Nancy logo" /><br />
    This view was rendered using the Nancy Razor view engine
</body>
</html>

Picture of the problem:

enter image description here

The pdb file for the project exists!

enter image description here

like image 725
Daniel Eugen Avatar asked Mar 10 '15 21:03

Daniel Eugen


People also ask

How do you fix the breakpoint will not currently be hit a copy of?

For this, simply open your "Solution Explorer", select your "Solution" and right click on it, Select "Clean Solution", once solution is cleaned, which will delete all the compiled and temporary files associated with a solution, select "Build" solution and then check if issue exists.

Why are my breakpoints not being hit?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.


1 Answers

If you don't have a controller connected to a view which calls the .cshtml view then it will never get loaded.

like image 134
Erik Sellberg Avatar answered Nov 02 '22 17:11

Erik Sellberg