ASP.NET App Debug: Breakpoint currently not hit - asp.net

I want to debug a ASP.NET application (Custom IHttpHandler) with Visual Studio 2008 and IIS7.
I compile the source, start debugging (F5) and IE loads. But my breakpoint (in method ProcessRequest()) is disabled. I get the error:
The breakpoint will not currently be hit.
No symbols have been loaded for this document.
I have no idea about ASP.NET programming. Do i have to set anything in IIS?
The PDB files are there. I wanted to check the symbol load status of my DLL but I couldn't find it.
When I open "Debug->Windows->Modules" I can't see my DLL in the list.
Only Windows DLLs and assemlies from GAC and so on.
Am I missing something?

Visual Studio -> Debug -> Attach to process
w3wp.exe
More info here: http://www.codeproject.com/KB/aspnet/ProcessAttache.aspx

For the archive: a breakpoint is only activated, once the corresponding assembly was loaded in the process space. So in order to enable a breakpoint which was set on a code line inside a DLL, you must run your app to the place, where the DLL is loaded. The breakpoint will than get recognized by the debugger and ungrayed in VS.

The problem for me turned out to be that the Properties->Build->Optimize code checkbox had been turned on in the Debug configuration. Turned it off, rebuilt, and debugging worked as normal.

Have you registered the HttpHandler in the <system.web> section instead of <system.webServer>?
In web.config:
<system.web>
...
<httpHandlers>
<add verb="GET" path="MyHandler.ashx" type="MyHandler, MyAssembly" />
...
</httpHandlers>
</system.web>
See Also
UltiDev Cassini and
web.config
settings
HttpHandler in IIS7 and
Visual Studio 2010

Solved it.
I had to open a page with an specific file ending while debugging. As soon as I opened the right page my DDL loaded and the breakpoint activated.

Related

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory

After finishing the John Papa course on Pluralsight- which is AWESOME by the way!!!)
I'm now creating my first SPA. I come from Desktop Application Developer background so excuse me if this question is newbie!
When I load the SPA instead of seeing the splash screen and then the main screen I'm getting this error message:
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.Most likely causes:
A default document is not configured for the requested URL, and directory browsing is not enabled on the server.
Can anyone help fix this?
1.Open up IIS Manager.
2.Add the website by right clicking on "Default website" and choose "Add application".
3.Enter any name as alias type and the load that website in the physical path and click OK.
4.Then go to the Features View of that Loaded Website and double click on the "Directory Browsing".
Click on "Actions" work space and change the "Disable" state to "Enable" state.
6.Then Refresh the Default Website.
7.Open the Visual Studio and go to that website. it will ask for reload , then click "yes".
8.it will add the following code in the web.config file.
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
9.Now run and see the error will disappear.
Go to Control panel--> Program and Features --> Turn widows features on or off (on the left side of windows).
Windows features Box will pop up in this : IIS --> WWW services -->
Common HTTP Request --> Directory Browsing (Enable this).
click OK.
In your web.config file - add this,
<system.webServer>
<defaultDocument enabled="true" />
</system.webServer>
and save.
It will start working. It worked for me after facing some initial glitches.
I was able to fix this using the answer from this site: https://devstuffs.wordpress.com/2012/02/29/how-to-fix-http-error-403-14-forbidden-the-web-server-is-configured-to-not-list-the-contents-of-this-directory/
This error occurs when you have MVC 2+ running hosted on IIS 7+, this
is because ASP.NET 4 was not registered in IIS. In my case I was
creating a MVC 3 project and hosting it on IIS 7.5.
To fix it, make sure you have MVC 2 or above and .Net Framework 4.0
installed, then run a command prompt as administrator and type the
following line:
32bit (x86)
%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir
64bit (x64)
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir
This is also one reason when this error appears.
Newbie programmers forget to mention the start page. Right Click on any form which you want to be displayed first when applications runs and Set as StartPage you wil find in the drop down menu.
Edit your web.config and add customErrors section in order to display detailed errors from your web server. Use mode="Off"
http://msdn.microsoft.com/en-us/library/h0hfz6fc%28v=vs.71%29.aspx
<configuration>
<system.web>
<customErrors mode="Off">
</customErrors>
</system.web>
</configuration>
Another option is to try to run the SPA in separate browser like Chrome typing the url directly, instead of running the SPA application in the Visual Studio debugger.
URL should be something like "localhost:13753". Check the port number of your development server. It will be different.
Then open the Developer tools by pressing F12.
Hit Ctrl+R to refresh and investigate the Netwok Tab. You can usually find more information about the error and what is causing it.

IIS 8.0 ASP.NET and Error 500.19

I can't seem to get any ASP.NET sites to run under IIS8 on Windows 8. Under IIS Express they are fine, but I've:
Installed IIS8
Installed ASP.NET 3.5 and 4.5 features in IIS
Created a valid application pool
Added a new Application in IIS manager pointing to my site
But I get:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Config Source:
-1:
0:
Any ideas?
ASP.Net applications come pre-wired with a handlers section in the web.config.
By default, this is set to readonly within feature delegation within IIS.
Take a look in IIS Manager, under the Server name → Feature delegation.
If Handler Mappings is set to readonly and your site web.configs have a handlers section, flip the value to read/write and see what happens.
Worked for me when moving to Windows 8 / IIS 8 / ASP.Net MVC 4.
Click "Start button"
in the search box, enter "Turn windows features on or off"
in the features window, Click: "Internet Information Services"
Click: "World Wide Web Services"
Click: "Application Development Features"
Check (enable) the features. I checked all but not CGI.
i'm using w10 technical preview
I had same issue, this is because the app pool doesn't have rights to the web site directory or web.config. Try to grant rights for "IIS_IUSRS" with : Read,Execute,List.
I had the same issue when moving a web application from IIS 7 to 8, and I solved it by installing the URL Rewrite module, which I had completely forgot. So check that you have the correct modules etc. installed on your new server/IIS.
You can install this module with WPI (Web Platform Installer) also.
If you have a new machine / formatted your machine, while installing IIS, make sure that you ticked installing ASP.Net (appropriate version).
Hint : Turn Windows Feature ON/OFF --> IIS --> Application Development Features --> ASP.Net 3.5 / 4.6
Recently I have upgraded to Windows 10 (IIS 10) & as I had forgot to install ASP.Net, I was facing this issue.
Other troubleshooting tips are:
2) Make sure you have given read permission to IIS_IUSRS group on
your application folder.
3) You may check if your Application Pool
has correct target .Net framework selected.
4) Make sure your
Web.config is proper (well defined XML) and has no errors. Thanks.
Look in the web.config for invalid config sections.
In the IIS manager I couldn't open any of the features such as Module etc.
In my web.config I had an invalid config section from a chart object that I used before:
<system.webServer>
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false" />
</httpHandlers>
</system.webServer>
After I removed it everything worked.
After trying all of the above, I was still stuck, so I decided to go look at the file referenced in my error message, "c:\some\path\web.config"
It was 3KB, and I renamed it to "_web.config", and the script immediately started working properly.
I assume the original created with how things were set before my myriad changes. With all the changes I did, it could now create a proper web.config.
Something to try if the above doesn't get you where you need to be, guys.
Finally sorted mine! Jesus.
I was using git hub for my project and downloading it to slightly different locations on each PC.
When I tried to unc to the config file the error mentioned I noticed it was actually the path the other pc uses. Couldn't fine this listed in the project at all so just right clicked the project file in VS and unloaded it, the loaded it again and it now works.
You probably tried this first but have you tried turning your pc off and on again? I tried all of the above first to no avail while simply doing this worked for me. Possibly one of my previous actions locked an important file in my project.

How might one turn off precompilation in IIS?

I'm trying to avoid having compile errors block the whole ASP site while we are in development. That is, I want each page to compile on first run instead of the whole site so that compile errors do not show up globally. That can be danged annoying when a dev takes off for lunch after saving with a systnax bleherror.
I've tried adding this to ye olde web config (changed from default "Always"):
<pages compilationMode="Auto" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
This did not have the desired effect. What can I change in the webconfig or using IIS to disable precompilation?
Web.config
<compilation batch="false" />
Indicates whether batching is supported.
If True, eliminates the delay caused by the compilation required when you access a file for the first time. When this attribute is set to True, ASP.NET precompiles all the uncompiled files in a batch mode, which causes an even longer delay the first time the files are compiled. However, after this initial delay, the compilation delay is eliminated on subsequent access of the file.
The default is True.
https://msdn.microsoft.com/library/s10awwz0.aspx
In IIS 7
To Use the UI
Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).
In Features View, double-click .NET Compilation.
On the .NET Compilation page, edit settings as necessary.
When finished, click Apply in the Actions pane.
http://technet.microsoft.com/en-us/library/cc725812(v=ws.10).aspx

Why isn't my IHttpHandler being called?

I'm trying to get a custom handler to work for a specific URL (or set of URLs) in ASP.NET 3.5.
The handler doesn't actually do anything significant yet - it just logs the request. I can post the code if anyone things it's relevant, but I really don't think it's being called at all. (In particular, for normal exceptions I get a custom error page and logging... here I'm just getting the vanilla IIS 404.)
Here's the relevant bit of the web.config file:
<system.web>
<httpHandlers>
<add verb="GET,POST" path="*.robot" validate="false"
type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
</httpHandlers>
</system.web>
(Obviously there's other stuff in that section too, but I don't think it's relevant.)
Locally, running under the dev server, it works fine. On my real box, I always get a 404. Everything under the web site directory itself is the same (replicated via svn). That includes the bin directory containing CSharpInDepth.dll, which I've verified contains CSharpInDepth.Wave.RobotHandler.
I try to fetch http://csharpindepth.com/foo.robot and just get a 404.
I've tried with and without the assembly name, specific URLs or wildcarded ones... nothing's working.
I'm sure I've just missed some simple flag somewhere in the IIS configuration, but I'm blowed if I can find it...
EDIT: It's IIS version 6. Attempting to add *.robot to the ISAPI filter now...
Well if the hosting box is IIS7 in integrated pipeline you need to add it into the other bit of the config:
<system.webmodules>
....
<modules>
<add name="RobotHandler" type="CSharpInDepth.Wave.RobotHandler, CSharpInDepth"/>
</modules>
....
</system.webmodules>
If it's IIS6 then you'll need to map *.robots to the ASP.NET ISAPI DLL.
(For the non-Skeets you do this as follows)
Open up IIS admin.
Right click on
the Web site you want to configure
and select Properties form the
context menu. This will display the
Web Site Properties dialog.
Select
the Home Directory tab and click the
Configuration button. This will
display the Application
Configuration dialog box.
Click
Add.
Select the aspnet_isapi.dll
from the .NET framework directory,
the extension you want mapped and
either All Verbs, or just the ones
you want to map.
Click ok.
Jon,
You'll have to configure the IIS script mappings to pass *.robot to aspnet_isapi.dll.

Why can't you build a website in release mode?

In ASP.Net, if I set up a web application I can configure it to be in release mode but with a website I can only set the configuration to be in debug mode. Why is this?
In web site projects each page is compiled dynamically upon first request. It will compile without debugging symbols unless you specify otherwise in the config file.
A Web Site's debug/release is controlled by the Web.Config file:
<system.web>
...
<compilation debug="true">
...
</compilation>
</system.web>
Set debug="true" for debugging, set debug="false" for release.
Probably because a Web Application compiles the whole website into one DLL. To run and debug pages requires recompiling the entire application. Whereas a website project compiles dynamically at the page level.
For websites one releases the source code to the site, there is no build to be done.
The code is built on site.

Resources