Custom error pages shown using IIS6 rather than web.config settings - iis-6

this is my first post on this great source of programming information.
I have developed new site for client and just doing some finishing touches.
I am trying to create custom error pages which would be read from web.config
<system.web>
<customErrors mode="RemoteOnly">
<error statusCode="404" redirect="404.aspx" />
<error statusCode="500" redirect="500.aspx" />
</customErrors>
It works well on local development machine and 404 and 500 errors are shown as required.
After compilation and publishing site to web server it doesnt work. IIS 6 keeps on showing original IIS 6 error pages like this 404 error:
The page cannot be found
The page you are looking for might have been removed,
had its name changed, or is temporarily unavailable.
Please try the following:
Make sure that the Web site address displayed in the address bar of
your browser is spelled and formatted correctly.
If you reached this page by clicking a link, contact the Web site
administrator to alert them that the link is incorrectly formatted.
Click the Back button to try another link.
HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)
I am not sure why is it doing this, I thought that web.config overwrites original IIS6 settings.
Ok I have found out that the problem is with the 404 .aspx page only. Error 500 is working fine and showing 500.aspx page. But not for 404.aspx. Please advice

The web config will only override IIS6 settings if the request is passed to the .NET ISAPI filter - for example, for pages ending with .aspx
If I browsed to a file or directory that didn't get to the .NET ISAPI it wouldn't use the web.config rules.

Related

IIS return 404 error but the files are exist

I have a website that implemented with .net core 2.1 and angular js.
I published this website on windows server that worked with IIS.
The problem is that, sometimes response of http requests for some files or request (the ajax request that called) is 404 error and sometimes it works correctly and I am sure that file is exists because if the user that faced with error, refresh the page, it will load correctly !
I attached a photos that compare same requests.
After many days I have this problem yet. I enabled IIS logs and attach one of xml log file here.

MVC application most page requests being redirected to /login.aspx?ReturnUrl=

I have installed an MVC4 application provided by a third party on our web server and most requests are being redirected to http://domain.com/login.aspx?ReturnUrl=requestedpage.
The website does not have any form of authentication and it does not have this or any other login page.
The default page loads but none of the page resources (like images, CSS, etc) loads as each of those is being redirected to the non-existent login.aspx page. Even a webservice request gets redirected.
I have done lots of searching online and tried the usual fix of <add key="autoFormsAuthentication" value="false" /> but it doesn't make any difference. I also tried <authentication mode="None" />.
It is IIS8.5 on Server 2012 and anonymous access is enabled throughout.
I just tried installing MVC4 directly on the server and this did not help.
Can anyone help?
This problem turned out to be caused by the anonymous user account not being set to the ApplicationPoolIdentity.
I fixed this after finding the answer on another question.

Custom 404 page for invalid request

I have implemented custom error pages in an MVC4 application. Basically I've added the following to my Web.Config file:
<customErrors mode="On" defaultRedirect="Error">
<error statusCode="404" redirect="~/Error/NotFound"/>
<error statusCode="500" redirect="~/Error/Index"/>
</customErrors>
Unfortunately, if someone uses a request that adds a path to a route the redirect doesn't take place. For example I have a Document method that takes an ID on the controller Content. The following request is valid:
/Content/Document/1
I get the 404 displayed when someone calls an url like this:
/BlaBla
/Content/BlaBla
Some users manage to add /BlaBla after the ID:
/Content/Document/1/Blabla
This is the case where my custom 404 page is not shown. How can I handle this?
A CatchAll - Route solved the problem. A question with an answer which made me find the solution:
MVC 4 catch all route never reached

How to prevent .net 4 handling 404 on IIS6

I have what seems to be the exact opposite of everyone else's problem! I am hosting a .Net4 site on IIS6, and while I want IIS to handle 404 errors (where I can configure it to send the error to an aspx page), it seems like .Net4 gets in the way by issuing a 302 redirect for the default page (which doesn't exist either) before I can get on with handling the 404 properly.
Basically, if I goto http://mysite/testProduct, .net4 issues a 302 for http://mysite/testProduct/default.aspx, which then goes on and gets handled by my error handling setup in IIS6 which is to redirect 404s to /404.aspx, which detects the product name, looks up an ID and does a Server.Transfer.
How can I stop .Net getting in the way? It's doubling the overhead of a page request, and will cause my products to get indexed with /default.aspx after them which I do not want.
AHA, Ben
EDIT: if I turn off CustomErrors in the web.config, .Net is still handling the error and not letting it pass to IIS at all - I see a 404 error page that is generated by .Net. So I get a 302 then a 404...!
Found the problem in the end - this was for an implementation of nopCommerce, which comes with UrlReWriter installed out of the box - it was this component that was causing the behaviour noted above...

Accessing OData service gives 404 "Resource not found error"

This could be a entirely hosting service related problem but I'll post it here in case it is a more common problem.
I'm running a OData service on my ASP.NET MVC 2 site which works fine on my laptop IIS but when I deploy it to my site at Winhost I get 404 Resource not found error when trying to access the .svc-file.
Earlier I had 2 different authentications on so I got the "System.InvalidOperationException: IIS specified authentication schemes 'Basic, Anonymous'...." error so I know that at that point the handler was trying to start the service.
After fixing that, I got the "Resource not found error".
The service is in /Services folder but it does not seem to matter. No matter where I put it it always gives me the 404 error. All the binaries from my local sites bin folder are in my remote sites bin folder.
Everything else on the site seems to be working fine.
If anyone has a solution to this, help would be much appreciated.
Finally got this figured out. Since my site is an ASP.NET MVC 2 site I need to ignore the route to the service. Otherwise ASP.NET will start looking for a controller for that URI.
So I added routes.IgnoreRoute("Services/ServiceFilename.svc/{*pathInfo}"); to my global.asax.cs and voilá problem solved.
Although I don't quite understand why the service works on my laptops IIS 7 without the ignored route.