http-status-code-404

Handle HTTP-Headers and status codes in controller

醉酒当歌 提交于 2020-01-15 11:37:08
问题 Im currently polling data with from an Database with an regular interval. For the backend I'm using C# and MVC2 as framework. As I'm fetching data with an interval of 10 seconds now I would like to in the backend in my controller implement some kind of conditional that will parse the http header and not fetch the data again if it has not been modified since last fetch. I'm not really sure how I would go about with this. Anyone have any good suggestions?! Regards 回答1: Why mess around with http

Handle HTTP-Headers and status codes in controller

好久不见. 提交于 2020-01-15 11:37:06
问题 Im currently polling data with from an Database with an regular interval. For the backend I'm using C# and MVC2 as framework. As I'm fetching data with an interval of 10 seconds now I would like to in the backend in my controller implement some kind of conditional that will parse the http header and not fetch the data again if it has not been modified since last fetch. I'm not really sure how I would go about with this. Anyone have any good suggestions?! Regards 回答1: Why mess around with http

Handle HTTP-Headers and status codes in controller

橙三吉。 提交于 2020-01-15 11:36:13
问题 Im currently polling data with from an Database with an regular interval. For the backend I'm using C# and MVC2 as framework. As I'm fetching data with an interval of 10 seconds now I would like to in the backend in my controller implement some kind of conditional that will parse the http header and not fetch the data again if it has not been modified since last fetch. I'm not really sure how I would go about with this. Anyone have any good suggestions?! Regards 回答1: Why mess around with http

apache2.4.7 not logging “404 Not Found” pages to error.log

混江龙づ霸主 提交于 2020-01-15 02:45:57
问题 I've seen questions about how to not log 404 errors to the error log, this is the opposite. For some reason my apache installation does not log 404 errors to my error log (or to my access log for that matter). I have set the error log properly and see errors going to it, but when I access non-existent pages I simply get my 404 error - the access (but not the 404 error) shows up in the access.log, but I don't see anything in the error log (which makes it hard, for example, to debug why some

Apache “File not found.” instead of 404. error document

倖福魔咒の 提交于 2020-01-14 14:33:08
问题 I want to set a custom 404 error document, but I have a problem with it! First, I have two RewriteRules in my .htaccess: RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ /$2/$3.php?lang=$1 [L] RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/([^/.]+)/?$ /$2/$3/$4.php?lang=$1 [L] So my URL looks like: /de-de/page/other/stuff and opend /page/other/stuff.php?lang=de-de Now it's time to set my own error document: ErrorDocument 404 /404.php If there is a mistake in "/de-de/page/other/" for example " /de-de/wrong

Is a “404 redirect” a legitimate redirect?

久未见 提交于 2020-01-14 13:45:30
问题 I have a situation where some users may come to mistyped pages, from links, etc. In most situations I can determine the correct page that should be displayed, so I want to redirect to the correct URL. Is a 301 Redirect appropriate in this case. 301 means "Moved Permanently", but in this case the document wasn't there in the first place. Is it legitimate to set a 404 Not Found header, then redirect to the correct URL? 回答1: I'd use 301. Moved permanently is appropriate in that it tells the

Should I throw a 404 to a request like /photo.php?id=123 if photo #123 does not exist?

…衆ロ難τιáo~ 提交于 2020-01-14 10:23:06
问题 The script will be called from a URL like example.com/photo.php?id=123 or example.com/photos/123 depending on if the have the pretty URLs featured enabled. If photo #123 does not exist, a request to example.com/photos/123 should throw a 404 error. But, what about example.com/photo.php?id=123 ? 回答1: The relevant RFC is 2616, specifically the sections on status codes, requests, and URIs. Specifically, the query string is considered part of the URI, so a 404 is the proper response since it means

Convert an exception into HTTP 404 response in the Application_Error

馋奶兔 提交于 2020-01-14 09:46:06
问题 First of all, quickly what exactly I want to achieve: translate particular exception into the HTTP 404 so the ASP.NET can handle it further . I am handling exceptions in the ASP.NET (MVC2) this way: protected void Application_Error(object sender, EventArgs e) { var err = Server.GetLastError(); if (err == null) return; err = err.GetBaseException(); var noObject = err as ObjectNotFoundException; if (noObject != null) HandleObjectNotFound(); var handled = noObject != null; if (!handled) Logger

HTTP 444 (No Response) instead of 404, 403 error pages?

∥☆過路亽.° 提交于 2020-01-14 07:46:10
问题 I always use "return 444" in the nginx config to stop crawlers that access my servers directly via IP or via the wrong hostname. It just closes the connection. Perfect. Now i want to use this response instead of the standard 404.html pages that nginx throws but i fail at configuring. error_page 500 502 503 504 /custom_50x.html; This works fine, but i cant "return 444" like here: server { listen 80; server_name ""; return 444; } Does anybody know a way to combine these two? Thanks in advance!

How to properly render custom 404 and 500 pages?

霸气de小男生 提交于 2020-01-14 05:09:18
问题 Is there are way to tell Rails to render your custom error pages (for example, the ones you write in your ErrorsController )? I've searched many topics, and the one that seems to kinda work was to add to your ApplicationController something like if Rails.env.production? rescue_from Exception, :with => :render_error rescue_from ActiveRecord::RecordNotFound, :with => :render_not_found rescue_from ActionController::UnknownController, :with => :render_not_found rescue_from ActionController: