elmah.axd/stylesheet not found error - asp.net-web-api

I Just installed ELMAH 1.2.2 from nuget to my WebApi 2 (5.2.3) project. It logs errors but elmah.axd's stylesheet doesn't load. And WebApi shows the following error:
{
"message": "No HTTP resource was found that matches the request URI 'http://api.sample.dev/elmah.axd/stylesheet'.",
"messageDetail": "No type was found that matches the controller named 'elmah.axd'."
}
I read some answers but doesn't seems related to my case.

I solved this error by preventing the WebApi's routing from catching requests to *.axd.
You can add the following line to your routing config.
httpConfig.Routes.IgnoreRoute("DynamicResources", "{resource}.axd/{*pathInfo}");
Now you can access elmah.axd's stylesheet and have a well styled log report page.

Related

Accessing API layer

I am trying to access an api function, for example I want to access the login function, I get the following error:
"message": "An internal error occurred during your request!",
Looking in the log file, the following log is there:
ERROR 2017-10-09 17:01:37,296 [11 ]
nHandling.AbpApiExceptionFilterAttribute - Processing of the HTTP
request resulted in an exception. Please see the HTTP response
returned by the 'Response' property of this exception for details.
System.Web.Http.HttpResponseException: Processing of the HTTP request
resulted in an exception. Please see the HTTP response returned by the
'Response' property of this exception for details.
I am using Postman to test. My URL is https://localhost:44347/api/Account/Authenticate. My header has Context-Type as "application/json" and in my Body I have the loginModel formatted as
{
"tenancyName": "tenantname",
"userNameOrEmailAddress": "admin",
"password": "123qwe"
}
Am not sure how else to proceed on this. Any ideas please? I have swagger installed as well.
I am using MVC + AngularJS template. I have not changed anything, just the default project.
Appreciate the assistance.
I have tested with Fiddler and it works correctly.
Note: make sure you type Content-Type correctly, on the question you typed Context-Type
Make a POST request! You may be missing this.

404 Not Found: Angular 2 can't talk to Spring Rest API

I followed Angular 2's Tour of Hero tutorial with in memory database. Then I created a Spring backend to supply data and want to integrate Angular2 with Spring's Rest API.
In Tour of Hero I only changed one line of code in hero.service.ts:
/* private heroesUrl = 'app/heroes'; */
private heroesUrl = 'http://localhost:8080/api/hero/all';
The link I changed to is the the Spring service endpoint, if I type the link in browser, it returns JSON data: [{"id":1,"name":"test"}].
However, I am getting error in Tour of Hero:
EXCEPTION: Uncaught (in promise): Response with status: 404 Not Found for URL: null
It looks like the spring endpoint of localhost:8080 is not found by Angular application running on localhost:3000. What could be the issue?
This was asked a while ago, but probably someone finds it useful.
Delete the following dependency from your package.json:
"angular-in-memory-web-api": "~0.2.4",
Remove it from node_modules directory, delete all InMemoryWebApiModule and InMemoryWebApiModule and InMemoryDataService-related code.

Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces

I am getting the below JavaScript error when I'm trying to access the application.
Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces
The browser is loading, but page is not displayed.
How is this caused and how can I solve it?
Uncaught SyntaxError: Unexpected token < in jsf.js.faces?ln=javax.faces
This will happen when the server returned a HTML document while the browser tried to download the mentioned JavaScript file (which is necessary for a.o. the functioning of <h:commandLink> and <f:ajax> in JSF 2.x).
You probably already know that HTML documents usually begin with a < and a JavaScript file absolutely not. Inspecting the HTTP traffic monitor and the actual HTML response should give clues as to what exactly it returned. Press F12 in Chrome/Firefox23+/IE9+ to see it. Perhaps it's a HTTP 4xx error? 401 unauthorized? Or 403 forbidden?
That can in turn happen if your (homegrown) security/login framework is badly configured. This problem is in turn not related to JSF itself. Basically, you need to fix/reconfigure it allow requests on /javax.faces.resource/*.
See also:
JSF page style missing when using login filter
Exclude css & image resources in web.xml Security Constraint
HTTP Status 403 - Access to the requested resource has been denied (CSS blocked?)

Call to PageMethods in WebForm returns 404 in MVC project

I am trying to add a WebForm to an MVC project to see if the code can be reused. Inside the WebForm, the JavaScript call to PageMethods returns failure:
The server method '{my pagemethod}' failed
There is no stack trace, the HTTP status code is 404 and the status text is null.
The page was working in the WebForm project and I confirmed that the parameters were passed correctly to the PageMethods call.
Is there something to expose the PageMethods of WebForm in an MVC project?
The HTTP 404 is caused by the page not being found.
Adding the following line to the RouteConfig solved the issue:
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");

Google Storage API 1.8.1 - Item getting issue

I am not able to get an item through Google Storage Service API:
Google.Apis.Storage.v1.StorageService service;
// ...
Google.Apis.Storage.v1.ObjectsResource.GetRequest request = service.Objects.Get(bucketName, uri);
request.Alt = StorageBaseServiceRequest<GCSObject>.AltEnum.Json;
Google.Apis.Storage.v1.Data resp = request.Execute();
I am getting GoogleApiException
"An Error occurred, but the error response could not be deserialized."
regardless of there specified item exist or not in the storage.
"request.ExecuteAsStream()" returns "Not Found" text only.
The same issue occurs when trying to set ObjectAccessControl through service.ObjectAccessControls.Insert() method.
Do you have any suggestions?
P.S. I am able to upload an item though without any problem.
Check if your URI/Object contains characters that need escaping like '/'.
It might lead (in .NET4) to response not found 404, meaning the object not found on Google cloud.
The google api for .net cannot serialize this error, so you get this useless message ("error response could not be deserialized").
To fix it, add to the web config:
<uri>
<schemeSettings>
<add name="https" genericUriParserOptions="DontUnescapePathDotsAndSlashes" />
</schemeSettings>
</uri>
I explained the scenario here: Slash, Google Cloud Storage & .NET4.

Resources