How to redirect to valid page if got 'The resource cannot be found'? Please suggest - web-services

I have a requirement to catch this exception or show some log if browse with below invalid filename :
http://localhost/ABC/xyx.asmx
Server Error in '/' Application.
The resource cannot be found.
Description: 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.
Requested URL: /.asmx
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4261.0

In web.config, you have two methods to custom error page.
When the error is caused by IIS or any other but not asp.net, IIS will shows error page like these.
If you want to change them, check the custom error pages in Error Pages module. Then delete the existing status code and corresponding page path, and add a new one.
When the error is caused by the asp.net, IIS will show error page like yello screen of death(YSOD). You can change it in section. If you want to show custom error page to remote visitor and YSOD to local vistor, you can set mode to RemoteOnly. You can configure this in .NET Error Pages Module.

Related

Absolute path of cloudfront while displacing custom error pages

I have an application which reside on EC2 instance, traffic comes from cloudfront--->ALB---->EC2 instance. If anyone is access the wrong url, the application throw an error page depending on the error.
Suppose, if I type a wrong url (abc.com/test/index.html) it will redirect to abc.com/error/404 (This is manage through application itself).
If, EC2 instance is down the error page are display through cloudfront using custom error page. But the problem here is, when I type the wrong url (abc.com/test/index.html) it will display the error page of 404 but will not change the url to abc.com/error/404 .
Also, the error page display through S3 bucket. Can anyone suggest any option to set this up in cloudfront.
Based on what you wrote, I suppose you're using ReactJS or similar since you're handling error pages in your application.
In order to do that in the ReactJS application, you need to add custom error responses for 403 and 404 codes.
For both of these, you need to set ResponseCode to 200 and ResponsePagePath to "/index.html" (since index.html is what's doing the routing in your application)

django error reporting request url - how to use this locally?

I have a django project which used the normal email admins on an unhandled exception when debug is set to False. ie in production.
I normally just review the error message and the stack trace. However I clicked on the request url link, which managed to recreate the error on the prouduction site (which then fired off another email).
What is this request url? Does it recreate the full http request (including the session etc..) which resulted in the original error?
Can I get the link to point to a local version of the site? (As after fixing a previous error clicking on the earlier request url has manged to create a recent error that we have been unable to reproduce, so it would be good to recreate this locally so it can be debugged.

Removing powered by Jetty

I am using Jetty server with embedded web app. However, whenever I hit any resource which is not present it serves a default page which shows a message "Powered by Jetty".
This page is being served from org.eclipse.jetty.server.handler.DefaultHandler.handle.
I want write a custom handler for this, however while trying to register custom Handler in jetty.xml file, I am getting syntax exception and server doesn't start anymore.
I was able to resolve this issue by doing some tweaks along with changes mentioned in Deactivate Jetty's default 404 error handler.

HTTP 404 error while invoking a local webservice in .NET MVC4

I am trying to learn webservices in .NET mvc4. I tried creating a new Internet application and adding a Web service (asmx) to the project.
By default, the VS adds a "HelloWorld" Webservice. When I try to run it in the browser, I do get the list of operations, service description(WSDL) and the details of the HellowWorld operation. However, when I try invoking the webservice, it gives the following error :
Server Error in '/' Application.
The resource cannot be found.
Description: 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 might be missing some basic step/setting I guess. Could some body help please. Thanks.
I got the answer from one of my colleagues :) .
When we invoke the service, the MVC tries to resolve the path as specified in RegisterRoutes.
Hence it tries to find a controller with that name and a method with the name same as that of the operation inside that controller. The resolution, ignore the paths with .asmx extension. You can do that by adding the following line in RouteConfig.cs :
routes.IgnoreRoute("{*x}", new { x = #".*\.asmx(/.*)?" });
and it worked. Thanks.

Login error to Sharepoint 2013 repository using openCMIS Workbench

using the OpenCMIS Workbench 0.8.0, I can load the sharepoint 2013 (GA) repositories fine but get the following error when I try to login to one of the repositories such as Documents:
"Invalid Argument: One or more of the input parameters to the service method is missing or invalid"
Found a blog with some instructions but those didn't work for me:
http://dhartford.blogspot.com/2013/01/sharepoint-2013-w-apache-chemistry-cmis.html?showComment=1359398536275#c6910049622927723676
Note: Here is the service url format that I am using:
http://myserver.xxx.com/MYSITE/cmis/_vti_bin/cmis/rest?getRepositories
Does anybody know what the problem is?
Here is the stack trace from Workbench:
> 11:05:17 DEBUG ncmis.client.bindings.spi.http.HttpUtils: GET http://MYServer/_vti_bin/cmis/rest/f8134afe-176a-4c48-9fd2-a9f97e5dc91d?getTypeDefinition&typeId=cmis%3Adocument
> 11:05:17 TRACE ncmis.client.bindings.spi.http.HttpUtils: GET http://MYServer/_vti_bin/cmis/rest/f8134afe-176a-4c48-9fd2-a9f97e5dc91d?getTypeDefinition&typeId=cmis%3Adocument > Headers: {null=[HTTP/1.1 400 One or more of the input parameters to the service method is missing or invalid.], Server=[Microsoft-IIS/7.5], SPRequestDuration=[124], SPIisLatency=[27], X-FRAME-OPTIONS=[SAMEORIGIN], Content-Type=[plain/text; charset=utf-8], Date=[Wed, 30 Jan 2013 19:05:02 GMT], X-SharePointHealthScore=[1], Cache-Control=[private], X-Content-Type-Options=[nosniff], X-Powered-By=[ASP.NET], X-MS-InvokeApp=[1; RequireReadOnly], request-id=[5ef0f99b-24ec-909f-6192-6eaf6feccabc], Content-Length=[167], MicrosoftSharePointTeamServices=[15.0.0.4420], SPRequestGuid=[5ef0f99b-24ec-909f-6192-6eaf6feccabc], X-AspNet-Version=[4.0.30319]}
> 11:05:17 ERROR hemistry.opencmis.workbench.ClientHelper: CmisInvalidArgumentException: One or more of the input parameters to the service method is missing or invalid.
org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException: One or more of the input parameters to the service method is missing or invalid.
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.convertStatusCode(AbstractAtomPubService.java:423)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:554)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getTypeDefinitionInternal(AbstractAtomPubService.java:821)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:88)
at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getTypeDefinition(RepositoryServiceImpl.java:137)
at org.apache.chemistry.opencmis.client.runtime.SessionImpl.getTypeDefinition(SessionImpl.java:518)
at org.apache.chemistry.opencmis.workbench.model.ClientSession.createOperationContexts(ClientSession.java:244)
at org.apache.chemistry.opencmis.workbench.model.ClientSession.createSession(ClientSession.java:195)
at org.apache.chemistry.opencmis.workbench.LoginDialog$2.actionPerformed(LoginDialog.java:204)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2006)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2329)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:398)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:253)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:247)
> 11:05:17 ERROR hemistry.opencmis.workbench.ClientHelper: Error code: 0
Another thing that I noticed is that none of the URLs from the service document work when I use them from a browser. So i think the service doc doesn't have valid urls.
Give the latest CMIS Workbench a try:
https://repository.apache.org/content/repositories/orgapachechemistry-166/org/apache/chemistry/opencmis/chemistry-opencmis-workbench/0.9.0-beta-1/chemistry-opencmis-workbench-0.9.0-beta-1-full.zip
Didn't have the time to post the solution but here is basically what I had to do after getting help from Microsoft. I was missing Step B below:
A. Activate the CMIS feature for your sub site
Go to the Sharepoint 2013 Central Administration
Click on the Sites link and then click on your sub site. Or navigate directly to it. eg http://myserver/mysitename
Click on the Settings icon (gear top right) and then select Site Settings
Under Site Actions, click Manage Site Features
Click Activate for the CMIS producer.
B. Check Alternate Access Mappings
Go to the Central Administration page
Under System Settings, click Configure Alternate Access Mappings
There should be at least two urls. One with server short name and one with server full name.
If the url is missing, click Add Internal Urls
For the Alternate Access Mapping Collection, click the No Selection link, change and select:
SharePoint - 80
Set the url such as http://myserver.usa.com (full domain name)
Set Zone: any such as Intranet
Click Save
My suggestion would be to:
start the Workbench, do not login yet
close the connection popup
open the Log window with the button on the top right corner
increase the log level to DEBUG or more verbose
try to connect
check the logs again, possibly posting them here
The actual root of the problem turned out to be a missing Alternate Access Mapping. Not sure why it was missing in the first place.
So I added an internal url that has the full server name address instead of just the short name. A microsoft dev helped me figure this out.
Remove any proxy settings from internet explorer before you launch OpenCMIS, also reset any system wide proxy settings: netsh winhttp reset proxy
Make sure your share point web app is set to accept only basic authentication as described in the blog post you mentioned
Removing the proxy from IE and system wide fixed my problem .. I can now login to sharepoint 2013 using OpenCMIS
ah before i forget the URL syntax should be http://server:port/_vti_bin/cmis/rest/?getRepositories
Good luck