CustomErrors only catches explicit page links - asp.net

I have custom errors turned on and when I go to
www.mywebsite.com/video/default.aspx it shows error which corresponds to 404 and this is fine
but when I go to www.mywebsite.com/video/ it shows a generic iis 404 error.
My other pages that have files work fine like
www.mywebsite.com/photo/ would redirect to www.mywebsite.com/photo/default.aspx because files exists and default is setup in IIS.
Please help. Thanks!

The 404 handler specified in the web.config only works for files handled by the ASP.NET runtime. This is why it is working for www.mywebsite.com/video/default.aspx and not www.mywebsite.com/video/, the generic error your observing is the one configured by default in IIS. You will need to go into IIS Manager and set 404's to be redirected to your PageNotFound.aspx.
Here's some more infomtion on configuring custom error messages in IIS 6.0.

Related

Custom Page 404 isn't shown on server (asp .net framework 4.8)

On our websites as someone visits a non-existing page, we dinamically create a 404 error page that returns a status code 404.
It works perfectly on localhost, but on the server the same page returns the standard 404 IIS (7.0) error
(IISError) instead of the custom one CustomError.
We can't edit the web.config file because we don't have a physical page to redirect to.
Is it possible that there is a IIS configuration that prevents our custom error page from showing?
There is a configuration setting in IIS. Click your application in IIS, and find Error pages settings.
For the error code, you could specify location of your custom page.

500 Internal Server Error accessing Image in IIS7

I have created an ASP.Net MVC4 site and deployed it to IIS7.
We noticed that the images in the css were not showing.
Trying to directly access the image file like this
http://.com/CircuitSearch/Images/CircuitSearchBackgroundTrans.png
returns the 500 error. Yes the filepath is correct.
Odd part if another site hosted on the same IIS works fine and can display images.
Change authentication for the site to Anonymous authentication/ application pool identity
I went into the IIS Log (usually under c:\inetpub\Logs) and discovered that I was getting error 500 with sub status of 19.
I looked up the causes for 500.19 via google and found the below link:
https://support.microsoft.com/en-us/help/942055/http-error-500-19-error-when-you-open-an-iis-7-0-webpage
Based off a clue that there could be a duplicate entry for some of the modules, handlers, or mime types causing an error, I commented out my system.webServer and noticed the images worked. I then commented out only portions of my web config and narrowed it down to a duplicate staticContent entry in my web.config.

IIS url 404's when it contains 'as' with no extension

I'm having an odd issue.
IIS 7 throws a 404 when trying to access url 'www.MYURL.co.za/dc/Fred.Basset'
We're handling the Fred.Basset part in the global.asax, but IIS is not even letting the request through.
I've managed to get it down to the 'as' being the issue - ie 'www.MYURL.co.za/dc/as' throws the 404.
If I give the url an extension (e.g.www.MYURL.co.za/dc/as.txt) I don't get the IIS 404 and it reaches the global.asax
I have no filters on IIS and nothing I can see that would cause this.
I've tried a URL Rewrite, but that only works if 'as' is not in the link.
Classic mode and Integrated mode problem
if use mvc on iis 7
select Integrated mode for iis
The URL rewrite was the issue - IT added a command to block certain file extensions, but it was blocking all occurences of those strings instead of just extensions

ASP.NET HttpHandler and WebResource.axd issues

I need a simple HttpHandler to handle specific non-existant paths in my ASP.NET project. I'm using sitefinity 4. I wrote the handler but whenever I try to run the site, I get a frustrating error
The WebResource.axd handler must be registered in the configuration to process this request.
I was putting the handler in the system.web part of the config but it looks liek VS2010 still uses IIS 6 for it's built in web server so I went ahead and switched it to use IIS 7 (local) and moved the registration of the handler to system.webServer and it works when I hit a non existant url but if I try to go to the site normally (valid url) I get that dang error again.
It worked once, giving me the correct site on a valid url but now it just continues to give me trouble.
How can I resolve this issue? I don't want to add that entry to the config as it wasn't there when I created the project and it only started when I added my handler.
EDIT: Only happens when I use Path="*" so how do I do a wildcard? I don't want to map a handler to catch a 404 page.
Froget it. No one seems to know even though I know i'm not the only one who has needed to do this. I got 404 to work but ONLY when I request a file, not a folder so thats a bust.
I found that Global.asax will hit under integrated mode so I just moved my code to the Application_BeginRequest() and it's working just fine. If anyone else has a better answer I will give them credit.
for iis7 and iis7.5, handlers are registered in system.webserver. the httphandlers and httpmodules in system.web are ignored and are used for IIS 6 and classic mode.
i hope this was helpful!

IIS7 Custom Error URL Redirects Not Working with non-physical files

So here's the issue. We run Sitecore, which does URL rewriting, and allows for something like example.com/Folder/Page.aspx to be a proper URL.
Now, "Folder" doesn't actually exist on the file system, and neither does "Page.aspx". But those URL's work, because ASP.NET does what it's supposed to.
Okay, so now say I try to go to a web page that doesn't exist like example.com/idontexist.html. This doesn't exist in on the file system, and doesn't use ASP.NET to resolve the file, so then we get a IIS7 404 Error.
Now, I want to change the 404 Error Page to a Custom Error Page, by using a URL. Say, the URL is example.com/ErrorPage.aspx. This page is actually, not a physical page, but an item in Sitecore.
In the Custom Error configuration in IIS Manager, I am trying to change the 404 Error to point to a "URL Redirect" and I'm using "/ErrorPage.aspx" as the URL redirect. When I try to then go to a URL that doesn't exist, IIS7 blows up with an error saying that it can't find /ErrorPage.aspx.
In IIS6, this isn't an issue, and everything works fine. But on IIS7, I redirect to a URL that isn't physically on the server.
Help!
to make a very long story short, here's the thing:
1) configure IIS so that 404 errors go to "default.aspx"
2) create a page that actually handles what you want to handle.
Reference links, SDN originals:
http://sdn5.sitecore.net/upload/sitecore6/handling_http_404_a4.pdf
http://sdn.sitecore.net/upload/sitecore6/dynamic_links_a4.pdf

Resources