Getting error with dots in the url - asp.net

I have a routed page with url like http://www.example.com/2/2332/example
Now when i give a period in the url http://www.example.com/2/2332/example. I am taken to the server error page:
HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make
sure that it is spelled correctly.
I would like to redirect to the same page http://www.example.com/2/2332/example or my custom 404 error page http://www.example.com/404.aspx.
I tried debugging but its not hitting the Application_Error event in the Global.asax.cs.
Any help to solve this issue?

The breakpoint is not hit because it is not an asp.net error. It is an IIS error. You have to modify web.config to redirect to a custom error page.

Related

Blank screen on custom error 404 page

In IIS 8.5, I have a default web site with a custom page that handles 404 errors.
This custom page is default.asp, which is also the site's default document.
When a 404 error occurs and the default.asp happens to have any other error (for instance, a SQL query timeout), IIS shows only a blank page and not the actual error.
If default.asp is accessed explicitly (no 404 error), the error is correctly shown.
Steps to reproduce this problem:
Configure a web site with a 404 error document pointing to default.asp
Create a default.asp with a divide by zero error: <%=1/0%>
Access /notexists.htm in your site. A blank screen is shown.
Access /default.asp. A divide by zero error is shown, which was also expected in step 3.
Any clues?
Errors will return a status of 500-100, internal server error. So you might want to seperate out the 404 file not found, and 500-100 error pages.

IIS7 - combination of ASP.NET customErrors, IIS httpErrors

I've seen a number of similar questions to this on StackOverflow and on other sites, but nothing that seems to resolve the issue I'm experiencing.
I'm trying to configure a site to return a 500 status code and a custom error page (static HTML file) for ASP.NET errors that would normally return a 500 where customErrors is set to "Off", and 404 status code for pages that our system reports as not being found (the 404 page is not a static page set via IIS, it's generated by our CMS system).
I'm part way there, but I've hit a bit of a brick wall.
At present, I'm able to return the correct 404 status code where our system returns a page with a 404 status code, but I'm now unable to return a 500 status code for ASP.NET server errors. I managed this by setting Response.TrySkipIisCustomErrors = true. My 500 errors, however, are proving more complicated. If I remove the customErrors config section from my web.config, I get the 500 error but it's the ugly ASP.NET YSOD. I can't seem to get this to point to a custom page using IIS at all, no matter what settings I use for the httpErrors config section and no matter what I set via the IIS GUI. If I add the customErrors section back, I get the custom error page as I'd expect, but I get a 200 or 302 error (depending on the value of redirectMode attribute).
Anyone got any ideas?
In terms of httpErrors config section I've tried the following so far:
Setting errorMode to "Custom" and specifying my static content for errors with a statusCode of "500" and a subStatusCode of "-1" (removing existing 500 error first)
Setting errorMode to "Detailed" and specifying my static content for errors with a statusCode of "500" and a subStatusCode of "-1" (removing existing 500 error first)
Setting existingResponse="PassThrough" for both configuration options above.
It seems you may be going above and beyond what you need to do, that is if I understand you correctly. Here is a good link
It seems like you what you need is to handle the global.asax Application_Error Event. This way you can handle it anyway you like and you dont get that ugly asp.net error screen. Any web app I create I put some code in there to handle errors so the user wont see any unformatted "blow ups"

Application_Error not fired for 404 in MVC 3 when url contains 4 or more path segments

I am trying to create a custom error page for 404 errors. I have implemented the Application_Error method in Global.asax.cs. For the most part this works great, but the method isn't getting called for URLs with 4 or more path segments.
The specific URL that I'm having trouble with is:
http://localhost/Area/Controller/Action/ID
If I remove the ID, my custom 404 age loads fine. The problem seems to be having 4 levels in my path (/Area/Controller/Action/ID). Any ideas?
I suspect your routes don't account for a URL with 4 parts. Try adding a catch all route as your last route to test this:
routes.MapRoute("Error404", "{*url}", new {controller = "Error", action = "PageNotFound" } );
Including (some of) your routes in your RouteConfig.cs question might also help.
Set the custom error page for IIS: In IIS rightclick your website/virtual directory --> properties --> custom errors tab --> set the 404 error to your error page.
Your custom errors will only fire for things that fit your route rules. Once all of your route rules fail and it does not find a page at that path it passes the error up to IIS. IIS then uses its 404 rule for object not found so you have to override that and point it back into your project to your custom 404.
Are you getting your IIS error page instead? Try this.
Open IIS, select your website, and choose the option "Error Pages".
Find the 404 status code, right click and go to "Edit Feature Settings".
Now, select "Custom Error pages" and change the "Path Type" to URL "Execute URL"
Finally, put in your URL as a relative value, and now it should redirect to this url on 404 errors.

asp.net calender control

I have used calender control in asp.net2.0, which on clicking of a image is openining in other window... with javascrupt window.open form... problem is on local environment is working fine...
but when deployed on server.. after opening image it showing The resource cannot be found.
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
/Calender.aspx
i mean when its working in local.. how come its not working on server..
As the HTTP 404 is saying: the resource has not been found at the location you are expecting it to be.
Check if the Calendar.aspx page is actually present on the server.
If it is, see why the link to that page is wrong in that environment.
If it isn't, check what has gone wrong with the deployment to the server

Make search bots to not crawl a deleted page?

Currently we are using a Kentico CMS for out web site and we used to have a page called pages/page1.aspx. We removed that page but every day the google, bing and yahoo sarch robot tries to read that page. Because the page doesn't exist the CMS throws the following error (in the log)
Event URL: /pages/page1.aspx
URL referrer:
User agent: Mozilla/5.0 (compatible; Yahoo! Slurp; http://help.yahoo.com/help/us/ysearch/slurp)
Message: The file '/pages/page1.aspx' does not exist.
Stack Trace:
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
// and the rest of the stacktrace
When we get too many of these errors the whole site crashes (have to clear .Net temp files and restart app pool). Basically I can go to a page that doesn't exist, hit refresh many times and take the site down. Extremely bad. However, first thing, how can I get the bots to not try to access this page?
Thanks in advance.
If it's just a single page, or a few pages that are causing this, modify robots.txt to tell the legitimate search engines not to check it.
I'd also check what HTTP response you're sending when the page is not found? You might be sending something that causes the spider to think it should keep checking? Instead of a 404 maybe you should try permanently redirecting to your home page?
Finally, WTF? I'd talk to the Ketnico folks about this bug.
I think that you have a configuration error. While a robots.txt file would hopefully correct this issue, bots can choose to ignore that file.
A better solution would be to setup your error pages correctly. What happens when you go to a page that doesn't exist? It sounds like your system is showing a yellow screen, which is an unhandled exception bubbling all the way up to the user. I would check your error page setup so that users (and robots) get redirected to a 404 error page. I'm guessing that when Yahoo and others see that 404 page, they will stop trying to index it.
Have you tried using a robots.txt file?

Resources