ASP.NET - nothing causes a 404 ! - what could cause this? - asp.net-mvc-2

I've just installed an old ASP.Net app on a new machine. It works except that I've noticed that no url from within the apps virtual directory will cause a 404 to be returned and I can't figure out what would cause this ?
So just to be clear:
http://myserver.example.com/myapp/login.aspx
returns 200 as it should because login.aspx exists but
http://myserver.example.com/myapp/login-no-such-url.aspx
returns 200 as well but login-no-such-url.aspx does not exist. The IIS log shows 200 for this url and the browser receives this :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv="Content-Type"
content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>
In case it was causing it I've removed all code from the Global.asax.cs / Application_Error function.
Other virtual directories on the same server do return 404's.
'Custom Errors' in the virtdir properties points at the standard 404b.htm and that file exists and contains the standard 404 text.
Where should I be looking to determine why IIS does not recognise non-existent URL's ?
EDIT1:
The only thing I can see in the web.config belonging to the virtual directory that seems relevant to this is :
<customErrors mode="Off" />
It's quite a complex web.config with a lot of application specific entries but I'm pretty sure that's the only relevant thing; however I would be interested to hear of suggestions for things in web.config that might be causing this.

Have you checked the web.config file? There might be some configuration there as to what to do with 404 errors etc.

Related

Need to preserve HTTP status code when using httpErrors custom 404 error using responseMode executeURL on Azure App Service IIS

I want to have all missing content/"bad" URLs redirect to our custom 404.html error page.
This is important for accurately recording 404 errors in Google Analytics.
The issue is that when the responseMode=ExecuteURL flag is set, then the custom error does not preserve the 404 status code, but always shows a 200 code. I can change this to responseMode=Redirect, but this then shows a 302 status code, before redirecting to the custom 404.html page.
All of this DOES work with a "File" flag set on the httpError… just not with the "ExecuteURL" flag which is required for our server-side Perl includes used to present Header/Footer page elements.
Ideally, we should be able to use the Azure App Service IIS web.config to set a custom error to:
always preserve/show the requested (missing) URL request in address bar (and dev tools)
always preserve/show the "real" HTTP status code (404) in the dev tools
allow the use of server-side includes to update header/footer elements using our current Perl setup
The below code works to preserve the requested URL in address bar, correctly shows the custom 404.html page with server-side header/footer content, BUT loses the 404 status code in dev tools (and Google Analytics)...
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404"
responseMode="ExecuteURL"
path="/404.html" />
</httpErrors>
Changing to responseMode="Redirect" only changes the status code to 302 before redirecting to custom 404.html...
If I change to use responseMode="File" this all works fine, but I then lose the custom server-side header and footers which are handled with Perl server-side includes...
EDIT:
To be clear, the custom 404 page is all HTML and Javascript, but also leverages some very old Perl server-side includes to add custom header and footer elements to the page. We are not using any .NET framework or .NET core pages...
This arrangement should be possible, but perhaps only with a different web server, not IIS? nginx, perhaps?
FINAL UPDATE:
Not a full answer, but our near-term resolution was to use nginx proxy configuration (which was already present and could be altered in nginx.conf) to preserve 404 error codes and present the proper custom 404.html static file.
I was also able to do this with Docker and nginx, so I know it is possible for a web server to deal with this situation...
I've determined that AFAICT there is no way for IIS web.config to handle this without using server-side code as Jason Pan suggested. So while he may be correct, that answer was not helpful for our needs.
UPDATE
When you use httpErrors in web.config, it must have code in your project to handle 400 and 500 in server side.
Due to your project just static web app, and no sever side code. So I suggest you can use hard code in httpErrors.
Like,
<error statusCode="404" responseMode="ExecuteURL" path="/404.html?httpcode=404" />.
The tag of httpErrors is used in servers such as iis. The 404 and 500 errors you want can’t be displayed directly in the browser. Because the httpErrors tag is used, the server will process everything and return it to the browser, so the HttpStaus you get is always 200.
PRIVIOUS
I probably know your question. Your program is .net framework or .net core, it is not clear for the time being. But I see the configuration tags in the web.config file.
In principle, the wrong request arrives at IIS and other servers, and the code level has processed 404 and other errors, so the returned HttpStatus value must be 200. There is no way to change it, but when a 404 or 500 error occurs, we can Processing and recording in Application_Error can also achieve the purpose you want to analyze.
So I tested it and based on the .net framework, you can download my sample code on github and give the following suggestions.
1. Add the Application_Error method to the Global.asax.cs file.
2. According to the Application_Error method, add an Error Controller.
3. Perform the test and the result is shown in the screenshot.
After decode the message. The content is
The controller for path '/a/b' was not found or does not implement IController..
We can custom error msg in Application_Error function. We can append HttpCode and other info.
Hi i found this workaround(ASP NET WebForms)
Web Config
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/ErrorDefault.aspx?httpcode=404" responseMode="ExecuteURL" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" path="/ErrorDefault.aspx?httpcode=500" responseMode="ExecuteURL" />
</httpErrors>
ErrorDefault.cs > Page Load
var httpCode = Request.QueryString["httpcode"];

Mailchimp No Host Exception when Subscribing Email to A List

I'm trying to send a subscription call, but got an error saying the the URL is invalid.
This is the URL I used:
https://us14.api.mailchimp.com/3.0/lists/<list-id>/members/
then I get this back in the response:
<HTML>
<HEAD>
<TITLE>Invalid URL</TITLE>
</HEAD>
<BODY>
<H1>Invalid URL</H1>
The requested URL "http://%5bNo%20Host%5d/3.0/lists/41e44e1bde/members/", is invalid.
<p>
Reference #9.cc6a1db8.1483891456.16189371
</BODY>
</HTML>
which translates to:
http://[No Host]/3.0/lists/<list-id>/members/
us14 is definitely the right data center according to the documentation so I'm not quite sure what's wrong.
It turned out that if you set HTTP header field "Host" in the request, it will always return this error. I tested this out by removing every fields one-by-one and this was the only one that caused an issue.
Many environments use the Host header for stuff like virtual sites where you are running more than one website behind the same IP Address (i.e. api.mailchimp.com and www.mailchimp.com could be on the same server) It is definitly possible for an error to be received if you set an invalid host since their proxies can't route it correctly. Normally, the host header is set automatically by the browser or HTTP client and usually not something you would override.
Are you still having trouble? If so, would be useful to see a screenshot of something like PostMan or https://ApiRequest.IO to see what your inputs are.

GWT RPC fails when launching app from different urls

I'm using urls to navigate to different screens inside my GWT app. For example:
http://127.0.0.1/home
http://127.0.0.1/info/contact-us
http://127.0.0.1/app/index.html
I have a servlet that serves the html containing the required script element for GWT (my GWT module name is "app"):
<script type="text/javascript" language="javascript" src="/app/app.nocache.html">
</script>
This is working great with GWT 2.6.1. In the browser dev tools it's possible to see that RPC calls are made to my RemoteService at http://127.0.0.1/app/rpc
The problem is when I upgraded to GWT 2.8, my app's RPC call endpoint is now different and wrong, depending on the URL used. For example:
http://127.0.0.1/home -> http://127.0.0.1/rpc
http://127.0.0.1/info/contact-us -> http://127.0.0.1/info/rpc
http://127.0.0.1/app/index.html -> http://127.0.0.1/app/rpc
For the above URLs the module is always correctly loaded and executed, however RPCs fail in the first two cases. only the last URL allows my app to make RPC calls.
The RPC endpoint can be set by casting the client-side service proxy to ServiceDefTarget and using setServiceEntryPoint(). As follows:
ourInstance = (MyRemoteServiceAsync)GWT.create(MyRemoteService.class);
ServiceDefTarget serviceDefTarget = (ServiceDefTarget) ourInstance;
serviceDefTarget.setServiceEntryPoint("/app/rpc");
However, the request payload still contains a reference to the incorrect module base. The http headers sent on the RPC request have incorrect values also:
X-GWT-Module-Base:http://127.0.0.1/foo/bar/
Is there a way to force the client's RPC mechanism to use the correct RPC URL /app/rpc? Or perhaps a way to set the module-base correctly?
UPDATE 1
Seeing the same behaviour in GWT 2.7.
Also, when deployed in a WAR the <module-hash>.cache.js file doesn't load because it is also requested relative to the url. This is very bad because it means that the module code won't be cached, since this url is different every time. The fix needs to be made in the selector <module>.nocache.js. Is anyone actually using GWT with url linking in the real world?
By specifying a <meta> element in the <head> element of the html document, the bootstrap nocache.js selector javascript will choose the correct module baseUrl. The baseUrl must be a fully-specified absolute url, and end with a /.
For my example, the exact element was:
<head>
...
<meta name="gwt:property" content="baseUrl=http://127.0.0.1/app/" />
...
</head>

Zephyr API to access test steps not working

I need to access test steps of a test case.
When I tried the following URL using CURL GET request,
http:///rest/zapi/latest/teststep//
I am getting the following error message
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at <jira_server> Port 80</address>
</body></html>
Same request using the browser gives {}
I got the issue ID using the REST API
"https:///rest/api/2/issue/testCaseId
So I am sure that the issue Id is correct.
Is this something because of latest zephyr update?
Can some one help me what is the issue with the request?
Unfortunately I think you have to purchase a plugin to use the ZAPI:
https://marketplace.atlassian.com/plugins/com.thed.zephyr.zapi
You can, however, connect to your database yourself and try to extract the test steps by looking for a table called [SOME_PREFIX_SUCH_AS_A7AEFBD]_TESTSTEP in your jira database. It holds an ID for the issue it belongs to so combining it with the jiraissues table you can fetch all test steps for a test issue you've made. Put that query result into an excel sheet and you have yourself a cheap extraction of your test steps.

Could Not Follow Redirect Path

I was debugging open graph for my new website and I have the following error:
Could Not Follow Redirect Path
and
URL returned a bad HTTP response code.
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.webcilento.com%2Fsite%2Feventi%2Ffiera-di-prova.html
This error occurs only in calendar section (http://www.webcilento.com/site/eventi/fiera-di-prova.html)
I'm using Joomla 3.2.1
Any ideas?
I think there is an error in the og:url open graph header which you have set.
The URL to your page is http://www.webcilento.com/site/eventi/fiera-di-prova.html but the open graph header says this:
<meta property="og:url" content="http://www.webcilento.com/site/site/eventi/fiera-di-prova.html" />
There is an extra "site/" part in that URL - Facebook is picking this up, visiting that URL which then returns a 404 - hence the "bad HTTP response code" message. If you change that <meta> to the following, it should work:
<meta property="og:url" content="http://www.webcilento.com/site/eventi/fiera-di-prova.html" />
If these headers are added by a plugin or by Joomla itself, then perhaps something is misconfigured? If you provide more information about how you are adding the Open graph headers to the page then we can assist with that.
What acute view! I haven't seen the double 'site' in the url!
Anyway the tag is added by a calendar plugin.
This is the code
// adding current url as url
if (isset($_SERVER['HTTPS'])) {
$protocol = "https://";
} else {
$protocol = "http://";
}
$fburl = $protocol.$_SERVER['HTTP_HOST'].KRequest::root().#route('option=com_ohanah&view=event&id='.$event->id.$itemid);
$doc->addCustomTag( '<meta property="og:url" content="'.$fburl.'" />');
I'll try to debug that variables.
After digging for 3 days came to the conclusion that name servers were configured incorrectly.
I am using Bigrock for the domain and GoDaddy for hosting, by mistake, I configured actual hosting provider host name in "Name Server 3" and "Name Server 4". But Facebook looks for the content in first server "bigrocks-1.com"(wrong server) server but does not find any hosting. Bigrock redirects request to next server "bigrocks-2.com", for which Facebook results into 'Using data from "URL" because there was an error following the redirect path.'.
Hope it may help you :)