Rendering ErrorPage shape manually in Orchard - error-handling

crosspost: https://orchard.codeplex.com/discussions/472090
Can we get the ErrorPage shape to render by a specific route like ~/Error/ErrorPage or something? 500 errors serve the Runtime Error page in my site and I'd like to redirect those via customErrors to the default ErrorPage or Orchard instead.

Write a controller and create a route that points to it. From your controller action, throw an exception.

Related

Where do I put the blazor.server.js script tag in a RazorPages app?

Right now I have it at the bottom of the _Layout.cshtml layout page that is used by every other page. The problem I'm having is that pages under the Identity area throw errors in the console when navigating to Identity pages:
POST https://localhost:5001/Identity/Account/_blazor/negotiate 404
and
blazor.server.js:1 Uncaught (in promise) Error: Cannot send data if the connection is not in the 'Connected' State.
These errors make me think I'm doing something wrong with how I enable Blazor Server in my RazorPages app.
So I'm wondering, should I only have the blazor.server.js scripts on pages that are actually using Blazor? Is there a way to make it available to Areas that putting it in the Layout seems to not do?
I believe this post answers my question:
How do I use blazor server-side inside a razor component library using areas?
By default, the SignalR service uses a relative path and was unable to find the _blazor/negotiate endpoint within an Area. The suggested code change in _Layout will make it use absolute paths and normalize to /_blazor/negotiate wherever you are in the page structure.
I know this is late but incase it help others.
I got this error when I was trying to add blazor to my existing app.
I added:
<base href="~/" />
at the end of the head tag of the _layout.cshtml file found in the shared folder.
enter image description here

Render different errors for different pipelines (:api and :browser)?

In my current Phoenix project I have both a :browser pipeline and a :api pipeline. I want to render different error messages for each pipeline. However, I'm not sure how to achieve it.
My router.ex is like:
scope "/api", AppWeb do
pipe_through(:api)
# ...
end
scope "/admin", AppWeb do
pipe_through :browser
# ...
end
I want all requests to non-existing routes under /admin to render a HTTP error template, but all requests to any other route to render a JSON error template.
In config.exs I have
render_errors: [view: AppWeb.ErrorView, accepts: ~w(json html)]
However, I'm not sure how to proceed with the error view.
It seems that the template_not_found/2 function will be automatically called, whenever a routing error occurs, however, this function doesn't have a conn argument. Its arguments are template and assigns.
Should I try to inspect the assigns to try to determine which route the incoming request was trying to access? Trying to inspect the template didn't seem to be helpful, and the template attempted to be rendered all seem to end with .html extension, even if I try to visit a route under /api.
As #JoséValim pointed out, the reason why I didn't correctly see JSON error messages is because I was visiting the pages via a browser. If I correctly set the header Accept: application/json in my request, it worked.
In template_not_found function in error_view.ex, it seems to suffice to just write Phoenix.Controller.status_message_from_template(template).

Custom nuxt 500 error page with preloaded state

Environment: Nuxt.js (Vue/Vuex/Node framework with SSR).
If user encounters an Internal Server Error, I want to use a custom Vue template, similar to the one I'm already using for 404 errors.
By looking at Nuxt source, it looks like the only way is to add a custom 500 page is to override the default .nuxt/views/error.html with my own custom error page.
I don't want just a static HTML page that the user must click out of to re-enter the app, though. I want it to still load the Nuxt app with some preloaded '500 error' state.
In Nuxt docs I don't see how to accomplish this. Any advice?
Things I have tried already:
Redirecting from error.html (doesn't work because of double redirect)
Iframe (works, but don't want to do it this way)

Polymer app not loading when using Apache reverse proxy

I have a Polymer app running on port 5901 of my VM, and am using Apache reverse proxy to serve the app from the following URL:
http://www.example.com/polymer
The problem is when I go to the URL in a browser, I can see the page title but the page is blank. I also get this error in the console:
Failed to load resource: the server responded with a status of 404 (Not Found) src/home-page.html
I'm assuming that I have to somehow add the /polymer subdomain to the default URL for the app, but I'm not sure how to do this.
EDIT: In response to comment:
The relevant link for Polymer 2.0 routing is https://www.polymer-project.org/2.0/toolbox/routing .
Updating the route. The route object is read-write, so you can use two-way data binding or this.set to update the route. Both the route and routeData objects can be manipulated this way. For example:
this.set('route.path', '/search/');
Or:
this.set('routeData.user', 'mary');

MVC 4 Web Api Routing - Use relative path for routing URL

Problem:
I am trying to call the ApiController from localhost:xxxx/Home/TestPage and get a 404 that the Requested URL: /Home/api/Test cannot be found.
If I make this call from the Index.cshtml page it works fine and I can navigate to localhost:xxxx/api/Test and see the desired JSON. I've tried adding ~/ to my MapHttpRoute routeTemplate but that throws an exception.
Question:
How do I remove /Home from the URL request?
Another example would be if I am on the page localhost:xxxx/People/TestPage and I want to hit multiple URIs such as localhost:xxxx/api/Hobbies, localhost:xxx/api/Pets and locahost:xxx/api/Vehicles. How would I set up the custom routing to handle this? As of right now with the default routes, I get the error that it can't find /People/api/Hobbies and so forth.
SOLUTION (Possibly):
I created a custom MapHttpRoute with the routeTemplate: "{page}/api/{controller}/{id}" and it works but I don't completely understand WHY and if this is good practice or not.
Home is your default HTTP controller. Home/api/Test is not a valid Web API controller route unless you have created custom routes. The out of the box default web api route is api/{controller}/{id}. So, if you had an API controller called home, it's URL would be localhost/api/home/id