MVC LazyInitializer Error Handling - model-view-controller

I want to have an error Page if My Aplication cannot connect to Database.
But for now I have sth like this:
Then If I step over I have an error in Layout where I check if IsAuthenticated it also shows an error in
<li>#if (WebSecurity.IsAuthenticated)
{
if (User.IsInRole("admin"))
{#Html.ActionLink("Admin Panel", "Index", "Admin")}
But it only happens if I am logged in.
If I am not logged in then it only shows an error which I showed in Picture,
Then if I click step over I get an error page in web browser which is a result I want to have.
Q: How to get an error Page if Database is not connected without going to VS10 to code view ?
I also have an error controller and it works for displaying error page if someone types wrong www address.

Related

How to trace and debug routing in Blazor (server side)

Something strange happens with routing in my Blazor application. If I put wrong URL like http://localhost:57222/xxxx - error in URL captures and processed normally, but if I put wrong URL like http://localhost:57222/xxxx/yyyy - Blazor engine not found anything, even http://localhost:57222/xxxx/yyyy/_framework/blazor.server.js, as a result I can not see a correct page "Sorry, there's nothing at this address."
In other case I try to use Microsoft.AspNetCore.Identity.UI with Blazor, but I can not receive debugging message "Route matched with {page = "/Account/Login", area = "Identity"}. Executing page /Account/Login" I expected and I have no redirection to Identity.UI components.
I have configured route in the same way
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
endpoints.MapAreaControllerRoute("admin_route", "Admin", "Admin/{controller}/{action}/{id?}");
endpoints.MapAreaControllerRoute("identityUI_route", "Identity", "Identity/Account/{action}/{id?}");
});
Admin panel and main branch without Areas working fine, but (1) something strange happens in error handling and (2) I have not call Identity.UI.
How is possible to trace and debugging this issue?

Unable to make index page secure and redirect to login page

I am using User Frosting V4. I learned about the routing concept.
Now I wanted to make my index page a secure page - which means only logged in users should be able to access the page.
If user is not logged in, he should be redirected to Sign In page.
I did the following :
I defined my own routing :
$app->get('/', 'UserFrosting\Sprinkle\Core\Controller\CoreController:pageIndex')
->add('checkEnvironment')
->setName('index')
->add('authGuard');
Now, when I access the site, I get the Exception. It does not redirect to the login page : account/sign-in
I get the following error :
UserFrosting Application Error
The application could not run because of the following error:
Details
Type: UserFrosting\Sprinkle\Account\Authenticate\Exception\AuthExpiredException
File: C:\wamp64\www\UserFrosting_V4\app\sprinkles\account\src\Authenticate\AuthGuard.php
Line: 50
It redirects to the sign in page in production mode.
https://github.com/userfrosting/UserFrosting/blob/master/app/.env.example#L4
Set that to production

NeoLoad Login 500 Error: Adf_Faces-30200

I'm trying to test java web application (jsf) that uses oracle adf-faces. When I record my test, the application is working fine but when I later check the user, then on login.jsf page, just before authentication and home pages, I get 500 Internal server error that says:
ADF_FACES-30200:For more information, please see the server's error log for an entry beginning with: The UIViewRoot is null. Fatal exception during PhaseId: RESTORE_VIEW 1.
Some more info: My login.jsf page is referred by previous login page that has jsession id appended to it. However, as far as I understand, neoload automatically handles jsessionid (I did try to set a parameter for it though and it didn't fix the error)
Also login.jsf page itself is a referrer to authentication page that in its turn is a referrer to a home page of an application, and the latter are both redirect pages (do not use manual definition) so they are not played during the check because of this error:
login.jsf page uses POST method and it has the following POST parameters: pt1:username, pt1:password, org.apache.myfaces.trinidad.faces.FORM, Adf-Window-Id, javax.faces.ViewState, Adf-Page-Id, oracle.adf.view.rich.DELTAS, event, event.pt1:loginCommandButton
I use set of users (I have a variable for username and password) and I handle javax.faces.ViewState manually with a jsf parameter (it used to give me errors).
I would appreciate any help greatly!

"Server Error" when users try to create a new account - Magento 1.7

I'm setting up our Magento 1.7 store, hoping to be ready for launch soon. I've noticed a problem:
When users try to create a new account, they fill out their info on /customer/account/create page just fine, then when they click submit, they get this 500 Error:
The website encountered an error while retrieving
http://example.com/customer/account/createpost/.
the account is actually created, however.
Similar deal on when users submit their email on the Forgot Password page, they press submit and get this:
The website encountered an error while retrieving
http://example.com/customer/account/forgotpasswordpost/.
no email is sent.
If you see this and know how to help with this prob, your advice would be much appreciated, truly.
In case it helps, we are using a theme, rather than default.
EDIT - (I was asked if I had checked server error)
My server errors show as this, for the above situations:
Forgot Password submit shows this error:
Fatal error: Call to undefined method Mandrill_API::addTo() in
D:\Magento\app\code\core\Mage\Core\Model\Email\Template.php on line
438
and
Create Account submit shows this error:
Fatal error: Call to undefined method Mandrill_API::addTo() in
D:\Magento\app\code\core\Mage\Core\Model\Email\Template.php on line
438
as well.
Here is 6 lines(437-442) of that Template.php file:
foreach ($emails as $key => $email) {
$mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
}
$this->setUseAbsoluteLinks(true);
$text = $this->getProcessedTemplate($variables, true);
[UPDATE]
I've learned that when I enter a random, fake email for Forgot Password, and press submit, a confirmation appears, saying something like "If this email exists, then a new email was sent to that email!", but when I submit an email of a real existing customer, then it gives me the 500 error I've mentioned.
Still nothing - if anyone out there sees this, and you have a bit of time to help solve this perhaps, may Talos bless you!
[SOLVED]
I turns out this was a problem with transaction emails.
Cause by an extension, Mandrill, which is added to magento when I installed the MailChimp extension, called "MageMonkey - MailChimp Integration by ebizmarts"
Once I enabled Mandrill, in config, advanced, all transactions and transaction emails work perfectly fine!
It's possible that it's a .htaccess or server configuration problem. Where is it hosted? Do you have a .htaccess file in the root of the installation?

MVC default redirect Error page doesn't always show

I have a custom error page in my MVC application that's just ~/error/ but when I turn Custom Errors on in the Web.Config like so:
<customErrors mode="On" defaultRedirect="~/error/" />
It only works for 400 errors not server-side 500 errors and instead gives me the following error message on a white page:
"Sorry, an error occurred while processing your request."
How can I just make every single error go to the defaultRedirect page?
500 errors should be handled by the MVC application itself. Custom Errors defined by the web.config are for errors other than 500 errors.
Basically, you need to use the RegisterGlobalFilter method (in global.asax) to add a new HandleErrorAttribute to the filter collection (you'll name the view to use for errors in the HandleErrorAttribute), then create a view that takes as its model System.Web.Mvc.HandleErrorInfo. There is no controller that handles these errors or sends the model to the view, so you can't just redirect to your error page.
You can get more information at http://community.codesmithtools.com/CodeSmith_Community/b/tdupont/archive/2011/03/01/error-handling-and-customerrors-and-mvc3-oh-my.aspx.
EDIT There is an alternative method, where all errors are handled through MVC, shown in How do I display custom error pages in Asp.Net Mvc 3?. Basically, you set up a protected void Application_Error()in your global.asax file to handle all errors, without going through web.config.

Resources