How might one turn off precompilation in IIS? - asp.net

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

Related

Web.config file debug="true" setting

I have run into an issue that when my web application's web.config compilation debug is set to true I am getting a vulnerability error on a security scan.
What I want to determine is if there is a way to have some type of web.config conditional block change the debug setting to use the correct value on debug builds and release builds. I have read that setting the property in each web page itself will do this and don't know if this is in fact true and are there any problems with this?
I would suggest <deployment retail=”true”/>.
You put this element into your machine.config on the production server and it overrides debug=”true” in your web.config and pages. In other words, you can happily use the debug and trace functionality on your developer machines but can be sure it is turned off on the production server. Scott Guthrie recommends this as best practice.

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.

ASPX page within a .aspx page with iframe throws 500.23 error

I'm trying to embed a ChartModule.aspx page within a Default.aspx page using an iframe.
The ChartModule has a button event which updates a chart. The ChartModule has its own ChartsModule.cs.
I'm getting this error:
HTTP Error 500.23 - Internal Server Error An ASP.NET setting has been
detected that does not apply in Integrated managed pipeline mode.Most
likely causes:
•This application defines configuration in the system.web/httpHandlers
section. Things you can try: •Migrate the configuration to the
system.webServer/handlers section. You can do so manually or by using
AppCmd from the command line. For example, from the IIS Express
install directory, run appcmd migrate config "Default Web Site/".
Using AppCmd to migrate your application will enable it to work in
Integrated mode. It will continue to work in Classic mode and on
previous versions of IIS. •If you are certain that it is OK to ignore
this error, it can be disabled by setting
system.webServer/validation#validateIntegratedModeConfiguration to
false. •Alternatively, switch the application to a Classic mode
application pool. For example, from the IIS Express install directory,
run appcmd set app "Default Web Site/"
/applicationPool:"Clr4ClassicAppPool". Only do this if you are unable
to migrate your application.
Detailed Error Information: Module ConfigurationValidationModule
Notification BeginRequest Handler
PageHandlerFactory-Integrated-4.0 Error Code 0x80070032 Requested
URL http://localhost:4161/Default.aspx Physical Path
C:\Documents and
Settings\singhm\Desktop\Temp\Trial2\Trial2\Default.aspx Logon Method
Not yet determined Logon User Not yet determined Request Tracing
Directory
Why is this?
While this may not answer your question directly, here is a thought:
If you have the option, consider turning ChartModule.aspx into a UserControl (ascx), which acts just like another "page" (same lifecycle, its own codebehind file, etc) but integrates more cleanly into an existing aspx page. The above link should be a good introduction to creating and using UserControls.
The error message contains a clue to the solution:
setting system.webServer/validation#validateIntegratedModeConfiguration to false
So make sure the following is present in your web.config:
<validation validateIntegratedModeConfiguration="false"/>
For example:
<configuration>
<!-- your existing settings -->
<system.webServer>
<!-- Add this to here.... -->
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
IIS 7 and ASP.NET are quite helpful these days with regard to to error messages and hints contained therein so you should take the time to read them.
I would really recommend using a usercontrol page instead of iframes in asp.net this way you can bind that usercontrol by doing
public override DataBind()
in that you can pass anything into that usercontrol page like refresh data, load certain data, etc..

ASP.NET App Debug: Breakpoint currently not hit

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.

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.

Resources