How to trace Error on a Deployed ASP.Net Application? - asp.net

VS 2008 / ASP.Net
I have a deployed a ASP.Net Web Application on Windows 2003 Server. For some reasons, it throws an error.
Application works great on my local computer. Either from source code or hosted on my local machine (Windows XP).
How to trace error on a deployed ASP.Net Web Application ?
Error :
Object reference not set to an instance of an object. 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.NullReferenceException: Object reference not
set to an instance of an object.
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.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
_Default.ExportRx30ToSalisburyAccessDB() +351
_Default.Button1_Click(Object sender, EventArgs e) +5
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
Source code : Which i am facing this error ..
try
{
Access.Application access1 = new Access.Application();
// Open the Access database for exclusive access
string sSalisburyAccessDB = Server.MapPath("~/App_Data/Salisbury.mdb");
access1.OpenCurrentDatabase(sSalisburyAccessDB, true, null);
// Drop the existing table data
access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "drug");
access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "patplan");
access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "plans");
access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "price");
access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "rx");
access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "patient");
access1.DoCmd.DeleteObject(Access.AcObjectType.acTable, "plntrak");
// Run the saved import
access1.DoCmd.RunSavedImportExport("SalisburyODBC");
// Close the database
access1.CloseCurrentDatabase();
// Quit MS Access
access1.Quit(Access.AcQuitOption.acQuitSaveAll);
Response.Write("successful");
}
catch (Exception ex)
{
Response.Write(ex.InnerException.Message);
}

Try running your app in IIS Express instead of Cassini (the built-in Visual Studio development web server). They behave differently and you might have a better shot at recreating the issue in your development environment. IIS Express runs just like real IIS so there are fewer surprises when you deploy your application.

Try deploying the application in debug mode, which should give you a specific line number and code file where the error occurred. Simply place this in your web.config file:
<configuration>
<system.web>
<compilation debug="true">
</system.web>
</configuration>
However, in general, you do not want to deploy to final production in debug mode. Instead, make use of try...catch blocks and good status/exception logging in your application to track down problems.

The easiest way to find where such errors occur is to split your methods down to just do one thing per method. For example, instead of adding a comment that say // Run the saved import, make a method of it RunTheSavedImport() and you will much easier be able to detect in which part of the code the error occurs directly from the stack trace.
What I can see , if the code you have provided is the full ExportRx30ToSalisburyAccessDB-method, the most probable causes for this error is that either DoCmd, AcQuitOption or AcObjectType of some reason are null. Since the stack do not enter Application it can only be caused by objects inside this method.

[ObjectDisposedException: Cannot access a closed resource set.] System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString) +1657 System.Resources.RuntimeResourceSet.GetString(String key, Boolean ignoreCase) +12 System.Resources.ResourceManager.GetString(String name, CultureInfo culture) +78 SourceCode.Workspace.OOBReports.ReportList.CreateChildControls() +347 System.Web.UI.Control.EnsureChildControls() +146 System.Web.UI.Control.PreRenderRecursiveInternal() +61 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Control.PreRenderRecursiveInternal() +224 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3394
simply reset your IIS server.

Related

Getting "The trust relationship between this workstation and the primary domain failed." error while debugging on long-working web page

Here's the short version of how I'm getting this error. Our company has a tool written in Aspx which is pretty barebones and used for handheld scanner devices. This page, when loaded detects to see if a user has logged on, if not, it prompts them to login, then it asks them to make a selection from a drop-down to specify their location and then it loads the main application menu.
For a long time, I've been able to run this application on my machine in debug mode. However, I'm getting a new error. When I run the application, I am prompted to login. I can login successfully and get to the location selector. On the next step, I can select my location from a drop-down and click continue.
On the back-end, there is a a redirect that takes you to home.aspx. Home.aspx is a blank page with a Menu user control. Both the Home page and the menu are super basic. I have put break points in both Page_Load methods and they execute entirely. After the home page and menu have loaded, something is breaking internally and I'm getting this error:
[SystemException: The trust relationship between this workstation and the primary domain failed.
]
System.Security.Principal.NTAccount.TranslateToSids(IdentityReferenceCollection sourceAccounts, Boolean& someFailed) +1271
System.Security.Principal.NTAccount.Translate(IdentityReferenceCollection sourceAccounts, Type targetType, Boolean& someFailed) +46
System.Security.Principal.NTAccount.Translate(IdentityReferenceCollection sourceAccounts, Type targetType, Boolean forceSuccess) +43
System.Security.Principal.WindowsPrincipal.IsInRole(String role) +135
System.Web.SiteMapProvider.IsAccessibleToUser(HttpContext context, SiteMapNode node) +193
System.Web.SiteMapNode.IsAccessibleToUser(HttpContext context) +18
System.Web.StaticSiteMapProvider.GetChildNodes(SiteMapNode node) +260
System.Web.XmlSiteMapProvider.GetChildNodes(SiteMapNode node) +29
System.Web.SiteMapNode.get_ChildNodes() +27
System.Web.UI.WebControls.SiteMapDataSource.GetNodes(SiteMapNode node) +57
System.Web.UI.WebControls.SiteMapDataSource.GetNodes() +347
System.Web.UI.WebControls.SiteMapDataSource.GetTreeView(String viewPath) +37
System.Web.UI.WebControls.SiteMapDataSource.GetHierarchicalView(String viewPath) +34
System.Web.UI.HierarchicalDataSourceControl.System.Web.UI.IHierarchicalDataSource.GetHierarchicalView(String viewPath) +11
System.Web.UI.WebControls.HierarchicalDataBoundControl.GetData(String viewPath) +26
System.Web.UI.WebControls.Menu.DataBindItem(MenuItem item) +50
System.Web.UI.WebControls.Menu.PerformDataBinding() +129
System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect() +111
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +76
System.Web.UI.WebControls.Menu.DataBind() +10
System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +114
System.Web.UI.WebControls.Menu.EnsureDataBound() +35
System.Web.UI.WebControls.Menu.CreateChildControls() +109
System.Web.UI.Control.EnsureChildControls() +97
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +163
System.Web.UI.Control.PreRenderRecursiveInternal() +163
System.Web.UI.Control.PreRenderRecursiveInternal() +163
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +906
I have turned on in VS that is should break on all exceptions. It's not breaking on any call in my code and, in fact, it doesn't break on any exception. It just throws up this error in the browser.
I've tried Googling this error, but nothing seems to work. We use Web Auth with roles, so I'm not sure what's happening. My local machine (or my personal user account) is what's used to call Db calls, but I've had no trouble with that in the past. In fact, within SSMS, I can execute any SQL code I want from within our Dbs, so this isn't a database issue.
Any clue what could cause this? I know you guys like to see code, but in this context, this doesn't have anything to with my code. There is a binding method for the menu, however, I've put a breakpoint at the earliest point in that method. This is the method (within my code) that should execute next after the Page_Load call. That breakpoint never gets hit before I receive this error. I have no clue what's going on. Thanks.
I awoke this morning to try running gpupdate /force to see if that would help at all. I have no clue what changed, but it seems to have fixed the problem.

Stored procedure found on localhost but can't be found when published

I have a stored proc on a server. The same server is used in both local development and the remote Dev server I have.
The site functions fine when I run it in debug on my local machine. When I publish it returns:
The stored procedure 'vts_spUserGetUserIdFromUserName' doesn't exist.
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 stored
procedure 'vts_spUserGetUserIdFromUserName' doesn't exist.
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.
Stack Trace:
[InvalidOperationException: The stored procedure
'vts_spUserGetUserIdFromUserName' doesn't exist.]
System.Data.SqlClient.SqlCommand.DeriveParameters() +3962
System.Data.SqlClient.SqlCommandBuilder.DeriveParameters(SqlCommand
command) +127
Microsoft.Practices.EnterpriseLibrary.Data.Database.DiscoverParameters(DbCommand
command) +154
Microsoft.Practices.EnterpriseLibrary.Data.ParameterCache.SetParameters(DbCommand
command, Database database) +114
Microsoft.Practices.EnterpriseLibrary.Data.Database.AssignParameters(DbCommand
command, Object[] parameterValues) +42
Microsoft.Practices.EnterpriseLibrary.Data.Database.GetStoredProcCommand(String
storedProcedureName, Object[] parameterValues) +70
Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteScalar(String
storedProcedureName, Object[] parameterValues) +38
Votations.NSurvey.SQLServerDAL.User.GetUserByIdFromUserName(String
userName) +226
Votations.NSurvey.WebAdmin.NSurveyAdmin.UserControls.LoginBox.ValidateCredentialsButton_Click(Object
sender, EventArgs e) +168
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11761917
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +150 System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+6016
The stored proc is definitely there. I have KDiff'd the two web.config files and there are no differences.
The only issue I can think of is that on the server it is in a Web Application as a sub application of another root site. Could that be the reason. It is inheriting database connection strings from the other application? If so is there any way I can stop that behavior?
Check the schema under which the Stored Procedure is created.
I might be possible that the Stored Procedure is created under your account, that is why when you are running it on local machine its able to find the SP and not when its running under some other account on sever.

How to add custom sign in page for FBA application

I have configured FBA for my web application which is working fine with default sign in pages. So i wanted to create custonm sign in page for that application. For that i have created a custom sign in page. but when i entered credential it gives me an error as below.
Server Error in '/' Application.
Object reference not set to an instance of an object. 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.NullReferenceException: Object reference not
set to an instance of an object.
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.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
LdapContosoAuthentication.Layouts.LdapContosoAuthentication.LoginCustmCntrlPage.Button1_Click(Object
sender, EventArgs e) +193
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +114
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +139
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +28
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+2980
Can anyone tell me how can i solved that error?
Put your custom page in layout folder and make below changes. So you can open your custom login page:
<authentication mode="Forms">
<forms loginUrl="/_layouts/CustomLogin.aspx" />
</authentication>
Have you made any change in delegate control (login control) of login.aspx page?

asp v2.0 iis7 machine.config amended to contain maxconnection="192" stopped calls working to third party web services

I added the following to:
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config
<system.net>
<connectionManagement>
<add address="*" maxconnection="192" />
</connectionManagement>
</system.net>
After saving the application was running fine. However calls to third party web services/web method (MICROSOFT MAPPOINT, another API unrelated to Microsoft i.e two independent references) failed to work. One of which returned the following error:
--------------------------------------
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.
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.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
WebApp.AddUpdate.LoadWebServiceRecord() +7740
WebApp.AddUpdate.MessageBox1_YesClicked(Object sender, EventArgs e) +51
WebApp.webcontrols.MessageBox.Yes_Click(Object sender, EventArgs e) +140
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +114
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +139
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +28
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2980
Version Information: Microsoft .NET Framework Version:2.0.50727.4206; ASP.NET Version:2.0.50727.4209
i.e exception above appears to have been created as it could no longer contact the service.
Remove the amendment in machine.config i.e remove the maxconnection rows and it all works fine again. Any idea why?
Do i need to declare the third party reference's in maxconnection?
if so would it be possible to provide and example?
Generally speaking, you shouldn't have to adjust it manually. ASP.NET 2 sets processModel to auto by default which among other things automatically scales maxconnections for the # of CPUs available (12N).
As to the error you're seeing, there must be more than meets than eye; the two are completely unrelated and there is no reason any maxconnection value would trigger a NullReferenceException in your application.
HTH
References:
http://technet.microsoft.com/en-us/magazine/2006.11.insidemscom.aspx
http://msdn.microsoft.com/en-us/library/7w2sway1.aspx

System.Data.OleDb.OleDbException: Unspecified error

I'm Totally new in ASP.net and currently working on a CRM application. This project uses .mdb files as backend but I am getting the following runtime error:
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.OleDb.OleDbException:
Unspecified error
Stack Trace:
[OleDbException (0x80004005):
Unspecified error]
EmployeeManager.isUser(String strUID,
String strPswd) in
d:\hosting\nitindia\App_Code\EmployeeManager.vb:481
Employees.BtnSubmit_Click(Object
sender, EventArgs e) in
d:\hosting\nitindia\Employees.aspx.vb:35
System.Web.UI.WebControls.Button.OnClick(EventArgs
e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
+13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) +1565
The above error occurs only when we upload these pages & test online. When running on localhost the error is not being raised.
What is the cause of this issue, and solution?
System.Data.OleDb.OleDbException: Unspecified error
This error mostly belongs to permission error, for this error we have mutiple solutions as per situation
Put the impersonate=false in web.config file.
If you want to put the impersonate = true in that case you need to provide the read/write permission to impersonate user on "C:\Documents and Settings\server name\ASPNET" folder or through process monitor utility you can check which file don't have sufficient permission.
If you have windows server 2008 then you will not found the ASPNET folder and still want impersonate=true then you need to change the configuration in IIS 7.5/7.0.
Go to IIS -> select your application pool -> Advanced Setting -> Process Model ->Identity=ApplicationPoolIdentity
Go to IIS -> select your application pool -> Advanced Setting -> Load User Profile = False
See here for more details.
Both of these conditions may cause this (rather unhelpfully named) error to occur:
The ASPNET account not having permissions to open the file.
The database file is locked by another user.
for answer finders :
try to look into https://learn.microsoft.com/en-us/iis/application-frameworks/running-classic-asp-applications-on-iis-7-and-iis-8/using-classic-asp-with-microsoft-access-databases-on-iis#using-process-monitor-to-gather-more-information and set Permissions on the Temporary Folders
PS in my case it was impersonate user who does not have access to current user temp folder C:\Users\`Username`\AppData\Local\Temp\

Resources