ASPX page within a .aspx page with iframe throws 500.23 error - asp.net

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..

Related

ASP.NET 5 custom error page does not render on Azure Website

I have a ASP.NET 5 site that I want to add custom error pages to. I'm used to adding entries in the web.config (from ASP.NET 4 days) but I want to use the new approach in ASP.NET 5. So I have the following in my Startup.cs class:
if (env.IsEnvironment("Development"))
{
app.UseErrorPage(ErrorPageOptions.ShowAll);
}
else
{
app.UseStatusCodePagesWithReExecute("/Home/Error");
app.UseErrorHandler("/Home/Error");
}
When I run locally using kestral my error page is displayed properly. However, when I deploy to Azure I get the very generic white error page when I try to test 404 errors:
"The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
I tried implementing this answer in my web.config and it does not resolve my issue:
https://stackoverflow.com/a/29539669/8320
This is the relevant part of my web.config:
<system.web>
<customErrors mode="Off" />
</system.web>
I have also ensured that ASPNET_ENV="Production" in the Configure / App Settings section of the Azure Website.
Any ideas? If I can provide more info let me know.
IIS is a tricky beast and we're still working through this in ASP.NET 5. When you run on IIS, we run through the middleware pipeline and then call back into IIS native modules if nothing handled the request. When you get a 404 that was un-handled by any middleware, it will re-enter the IIS pipeline and trigger IIS specific error pages. The UseStatusCodePagesWithReExecute middleware still runs, but by then, IIS has already sent the headers and body to the client (browser in this case).

ASP.NET MVC site as a virtual directory under Web Pages site?

I have a main site, example.com, implemented in ASP.NET Web Pages and deployed on Azure Websites. I then have another site which is implemented in ASP.NET MVC which I'd like to deploy as example.com/subsite. I have created a virtual directory using the Azure Portal but when I deploy my files there, I get this very nasty error:
An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.
I don't get any additional info, there is no YSOD, there are no failed request tracing logs when I enable them, just nothing.
I'm just guessing but probably my web.configs are somehow colliding. For example, under some circumstances, my request to /subsite/something gets caught by HTTP 500 error handler in the super site.
I need some very general advice here; is it at all possible to deploy two ASP.NET apps with their own web.config's in the same site, just using the virtual directories? If it is possible, are there some typical gotchas that I am possibly falling for?
I could solve similar creating a virtual application inside a wordpress website. In my case, I've put the following configuration in wordpress's web.config :
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
</configuration>

404 handling - Difference between local ASP.Net (C# 4) and remote server (live)

I'm facing a problem:
I do want to do URL rewriting with ASP.Net
It works perfectly using my local settings, but once on the server it doesn't work as expected.
Local
Request to /unavailable-file.aspx gets well in the Application_Error (Global.asax.cs) and then is being redirected to /404.aspx
Request to /unavailable-random-folder or any other file gets well in the Application_Error (Global.asax.cs) and then is being redirected to /404.aspx
Remote
Any request to a .aspx file WILL be catched in the Application_Error
Every other request (.jpg, folder, etc...) will NOT be catched at all and thrown into the default 404 page error
My problem:
Yesterday I was installing my new website to the server and I saw that Application_BeginRequest was not even fired AT ALL on my server, when it was every time (for every file or folder requested) in my local computer (with visual studio).
I had to create an HttpModule and now I am successfully getting the events firing... but not for non .aspx requests.
Everything seems to be bound on the URL : when it ends with .aspx it's correctly managed and when it's not, it's just not managed at all.
What should I do to catch every Application_BeginRequest even for non aspx page?
I have that in my web.config to try to force the 404 errors into my page:
<customErrors mode="On"
defaultRedirect="404.aspx">
<error statusCode="404" redirect="404.aspx"/>
</customErrors>
But as I said, as long as it's not a request ending with .aspx it's not being redirected and I get the default ASP.Net 404 error.
(My host is "reliablesite" if it can help, and I have the settings of the 404 errors pointing to my 404.aspx page inside the manager (shared hosting), it does not change anything)
I wish everything would work as in local mode.
If you have any tip on how to resolve that problem let me know.
In the development web server every request is handled by the aspx engine, as that's all there is. In the live server different file types are handled by different engines.
To make the live server use the aspx engine for every request you have to change the configuration in IIS for the web site.
Related: ASP.net web.config doesn't catch all 404's
The solution of this problem is given here when you have a shared environment:
Active the ASP.Net Integrated Pipeline in your shared environment settings (a thing that is available since IIS 7)
Add this to the web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="RedirectHttpModule" type="RedirectHttpModule" />
</modules>
</system.webServer>
Where RedirectHttpModule is a custom module handling Application_BeginRequest for example.
The "runAllManagedModulesForAllRequests" means that all managed modules will be invoked for all requests to web application.

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster

I've read countless posts on this topic, and tried several solutions but I'm still seeing this error. I'm running iis6, .NET 2.0 on a single server. When clicking a link on my form, and new page is opened that allows the user to enter a bunch of data (it's an order form). When clicking save, I see this error:
"Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster."
I've verified that the page has finished loading before clicking the save button.
I've tried:
adding enableViewStateMac="false" to the Page directive
adding this to the web.config <machineKey validationKey="AutoGenerate,IsolateApps"
decryptionKey="AutoGenerate,IsolateApps"
validation="SHA1"/>
adding viewStateEncryptionMode="Never"in the page tag in the web.config
adding enableEventValidation="false" in the page tag in the web.config (which I'm not sure I should do)
adding renderAllHiddenFieldsAtTopOfForm="false" in the page tag in the web.config
And I've checked for coding errors, but everything is working fine locally. Does anyone have another suggestions? Thanks

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