http-status-code-404

ZF2 - How to change the error/404 response page? Not just template but to set a new ViewModel

ε祈祈猫儿з 提交于 2019-12-04 08:55:38
By default the page is set like this in the Application module.config array: 'template_map' => array( 'error/404' => __DIR__ . '/../view/error/404.phtml' I want to change the page. I want new ViewModel for it full of variables. It means that simply to change the template is not enough: 'error/404' => __DIR__ . '/../view/error/my_new_404_template.phtml' But I can't understand how to make it. I can't see the way the request comes to the 'error/404' . How to create new ViewModel for it? How to attach variables to it? How the route comes to 'error/404' to catch it to change? For example, I have

How to create custom 404 Error pages in ASP.NET MVC 3?

点点圈 提交于 2019-12-04 08:49:34
what is the best way to create custom error pages in ASP.NET MVC 3? The one I am particularly interested in is a 404 error, but also 403, and others. I am new to the MVC framework, traditionally I come from a PHP background, but am learning quickly. I did my research before posting this question and came across this link: Custom error pages on asp.net MVC3 That solution seems simple although when I try to implement that on my machine, I get a problem with the following line: IController errorsController = new ErrorsController(); inside the Application_Error() function. It says "The type or

Redirect 404 or just 404 header

半城伤御伤魂 提交于 2019-12-04 08:31:24
I'm currently coding a site and I want to know the best alternative. Should I add header("HTTP/1.0 404 Not Found") without redirecting or should I redirect and add a 404 header? Redirecting means "What you asked for is actually over here". If it isn't found, then it isn't found. Don't redirect. Output a 404 status code, and then an HTML document that explains that whatever was requested wasn't found. You can then suggest an onwards journey by, for example, providing links to the main sections of the site or performing a search based on keywords extracted from the URL. (The practical

How can I get NSURLResponse body?

江枫思渺然 提交于 2019-12-04 08:15:12
问题 I'm writing an application that connect with a server using NSURLConnection . In the delegate method didreceiveresponse , if the status code is 404, I cancel the connection and I would like to show a message with a custom error that is generated in the server. The problem is that from response object, I only can get statuscode, headers, mimetype, etc. but no body. How do I get the body message from NSURLResponse ? 回答1: Why do you cancel the connection? After all, 404 can have content body as

Return Custom HTTP Status Code from WebAPI 2 endpoint

血红的双手。 提交于 2019-12-04 07:59:57
问题 I'm working on a service in WebAPI 2, and the endpoint currently returns an IHttpActionResult . I'd like to return a status code 422 , but since it's not in the HttpStatusCode enumeration, I'm at a loss as to how it would be sent, since all of the constructors require a parameter of HttpStatusCode As it stands now, I'm returning BadResult(message) , but returning a 422 + message would be more descriptive and useful for my clients. Any ideas? 回答1: According to C# specification: The set of

Eclipse webserver path mapping issue with PHP project

旧时模样 提交于 2019-12-04 05:30:12
问题 I've been reading through the other posts on this topic tried what was suggested in the post and still having the same issue. I can run my php in an external browser but not in the eclipse browser. The workspace in the htdoc directory. I have gone through the debugger and Run Configurations as well. I'm running xampp along with eclipse. So in eclipse I have a php file to run I select run as webpage: This is what happens. Object not found! The requested URL was not found on this server. If you

Django ignoring changes made to URLS.py file - Amazon AWS

妖精的绣舞 提交于 2019-12-04 04:26:40
问题 I just created an EC2 instance and created a Django app and am using Amazon servers. Normally when I make a change to my Djnago app, I updated it by doing git add . git commit -m "change" git aws.push I recently made changes to my URLS.py file and did the three steps above. I then went to my website and for some reason when I visit a URL, it gives a 404 not found error and says Using the URLconf defined in myapp.urls, Django tried these URL patterns, in this order: 1. ^$ The current URL,

Using static files in custom 404/500 pages in Django

ぃ、小莉子 提交于 2019-12-04 04:02:40
I would like to use some custom CSS and images on my custom 404/500 pages that I made. Django doesn't include the STATIC_URL variable in those pages though. What would be the best way to accomplish this? I also tried making a custom 404/500 view and rendering an arbitrary HTML file but it didn't work out so great. Here's how I would do it: # urls or settings handler500 = 'mysite.views.server_error' # views from django.shortcuts import render def server_error(request): # one of the things ‘render’ does is add ‘STATIC_URL’ to # the context, making it available from within the template. response

MVC 4 catch all route never reached

左心房为你撑大大i 提交于 2019-12-04 03:19:47
When attempting to create a catch all route in MVC 4 (something I've found several examples of, and based my code on) it returns a 404 error. I'm running this on IIS 7.5. This seems like a straight forward solution, so what am I missing? One note, if I move the "CatchAll" route above the "Default" route it works. But of course then none of the other controllers are ever reached. Here is the code: Route.Config: routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); routes.MapRoute( "CatchAll", "

IIS7 Hijacks My Coldfusion Error Page

孤人 提交于 2019-12-04 03:15:40
问题 In my exception handling file, I set a statuscode to 404 and then render n HTML page, for the error page (think fail-whale). <cfheader statuscode="404" statustext="Application Exception"> <html><head><title>Error</title></head><body><h1>There was an error yo!</h1></body></html> This is obviously over simplified, but just to make sure everything was demonstrated. What I have found is that from a ASP.NET request, they can set a variable "Response.TrySkipIisCustomErrors=true" to keep IIS from