Send exception from app_codevb in a web site asp.net - c#

I've a question. In a web site created in asp.net with vb.net in code behind, how I can show message of exceptions from methods in app_codevb folder.
Example a method return a table with a list of customers, but occurs a error of timeout or error in sintax.
How I can show the user in the form the error occurred in app_codevb folder?

If you don't do anything then it will automatically show any unhandled errors on the page.
Somewhat in this format
Server Error in '/WebApp' Application.
Error Message...
Description: ...
Exception Details: ...
Source Error: ...
Source File: ...
Stack Trace: ...
Version Information: ...
However, it is not a good thing. It looks ugly and breaks your site. It also shows your immaturity in programming besides opening your site for attacks. The better way is to use Try... Catch blocks where there is a possibility of errors occurring in your application and handle the error appropriately.

Related

XmlException and CryptographicException when running blazor web server app

I receive these two exceptions when I run my blazor web server app:
XmlException: Root element is missing.
CryptographicException: An error occurred while trying to encrypt the provided data. Refer to
the inner exception for more information.
I just created the project and run it... I didn't write any piece of code .
Any help is appreciated because I didn't find any solution till now.
I have found two solutions to fix this issue if someone faced it later.
links to solution:
https://github.com/dotnet/aspnetcore/issues/12830#issuecomment-517907537
https://github.com/dotnet/aspnetcore/issues/12830#issuecomment-606173185

Server Error in '/' Application using Azure

The problem is that the web page was not deployed after migrating using another computer and also, the migration file was deleted.
the error was
The model backing the 'ProjectContext' context has changed since the
database was created. Consider using Code First Migrations to update
the database
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The model backing
the 'ProjectContext' context has changed since the database was
created. Consider using Code First Migrations to update the database
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
is there any way to solve this problem from my computer? or there is another problem behind this?
What the message says is that your database model is out of sync with your Entity Framework 'Code First' model / code.
To overcome this issue, you can use Code First Migrations. The linked tutorial on MSDN explains what you should do. You effectively have to use the Package Console and some C# code to migrate one version to another. This is something you have to do while coding the project. If you release it, the code can automatically update your database model to match your Entity Framework Code First code.

Parser error in c# application

My system shuts down and then my application starts giving me the below error
Parser Error
Description: An error occurred during the parsing of a resource
required to service this request. Please review the following specific
parse error details and modify your source file appropriately.
Parser Error Message:
'Project_management.ProjectDetails_Datewise' is not allowed here
because it does not extend class 'System.Web.UI.Page'.
I have deleted folders from temporary file.
Create a new file same way you have tried the last time. Check the difference between both file's aspx page (not the codebehind).
Copy the namespace from newly create file and it will work.

DebugDiag not seeing exception

I am supporting an application team and they have an issue with their web page - the below is shown:
Retrieving the COM class factory for component with CLSID {0002E569-0000-0000-C000-000000000046} failed due to the following error: 80070005.
I have looked around here and other sites but cannot find the culprit of the access denied object. The object itself is registered in the registry as "Microsoft Office Spreadsheet 11.0".
I have decided to take a dump of the this whilst it happens so I can see where in the code the problem is occurring and possibly track down some info from there.
I have tried debugdiag and tried loads of exception settings however when I go to the website and raise the exception of System.UnauthorizedAccessException it is not saving any dump.
There is no default exception in the exception list called 80070005 so I am putting it down as a .NET 4.0 app and 80070005 - this is the Hex value of access denied as appears in the error message.
Any ideas what settings I should choose for debugdiag to see the exception?

Schema specified is not valid. Errors: error 0002: Request failed

I have an EntityFramework project running off MySql that runs great locally as well as on a dedicated server, however I'm trying to move this project to HostGator and I'm receiving the following error:
Schema specified is not valid. Errors:
App_Code.WireWeld.ssdl(2,88) : error 0002: Request failed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.MetadataException: Schema specified is not valid. Errors:
App_Code.WireWeld.ssdl(2,88) : error 0002: Request failed.
I know the database is correct as I can connect via Navicat and see its contents. I'm pretty sure the connection string is correct, I have the proper username and password.
I'm really stuck on this one and would appreciate any help possible.
If you are using more than one model in your project I advice you to have a look into that topic as it describes possible solutions to the problem.
If you are not using multiple models than this looks like a file permission issue to me.
Perhaps in the hosted environment, the account underwhich your application is running doesn't have access to where the metadata files are located?
You should make sure you have permission (read/write are required). If this is not an option for you than the only go would be to embed the metadata in the assembly directly and use a res:// style connection string.
If you're using SQL server and have 2 projects - one is a class library and the 2nd one uses that class library in main project, then place both dll from class library project to main project refrence.
1-EntityFramework.dll
2-EntityFramework.SqlServer.dll

Categories