IIS7 giving Object reference not set to an instance of an object error - asp.net

I have an IIS7 application that is using the .net 4.0 framework. The application pool has the rights (read/write/execute) on the folder of the application and has (select/read/connect) rights to the Database. IIS7 accept the aspx files and everything seems fine int eh settings however i am getting a 404 error when I am calling ti from outside of the server.
When I go in the server and call the http://localhost link, i get this error
Server Error in '/Phonebook/PhoneBook' Application.
--------------------------------------------------------------------------------
Object reference not set to an instance of an object.
Description: An unhanded 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.]
PhoneBookApplication.DBUtils.Execute(SqlCommand command) +399
PhoneBookApplication._Default.FillddlSearch() +156
PhoneBookApplication._Default.Page_Load(Object sender, EventArgs e) +54
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
System.Web.UI.Control.LoadRecursive() +70
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3047
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
If I call a default-defaut.html file, it works, but not if I call the default-defaut.aspx. But in the daufault pages settings, both aspx and html are there.
Also, it seems to have something to do with the sql server, but I do not understand where to look to debug that
I have no idea what is doing this. Can someone help?

The method DBUtils.Execute seems to have an error. What do do you have on the page_load or any event before the page_load ?

The error is telling you exactly where the problem is:
Your line 399 of the DBUtils class has a bug:
PhoneBookApplication.DBUtils.Execute(SqlCommand command) +399
IIS is not the problem. If you are getting a 404 error is because you are not going to the correct URL.

Related

IIS appwhen adding a binding. servername.domain.com/app works, but appname.domain.com/app doesn't

I have a server whose sole purpose is to host a prebuilt IIS app from a vendor.
The server has been built, IIS is working, and with everything installed, the app is accessible from http://servername.domain.com/app
I want to add an alternate URL, to be http://appname.domain.com/app, for ease of use and cleanliness.
I added the binding on both ports 80 and 443 with our site cert, using all unassigned IPs and none of the boxes ticked.
Despite changing nothing but the bindings, I'm getting the following error attempting to use the newly bound URL:
Value cannot be null.
Parameter name: source
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.ArgumentNullException: Value cannot be null.
Parameter name: source
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:
[ArgumentNullException: Value cannot be null.
Parameter name: source]
System.Linq.Enumerable.Where(IEnumerable`1 source, Func`2 predicate) +6466184
Xtraction.Web.Auth.Authenticate.HasSingleActiveProvider() +185
Xtraction.Web.Auth.Authenticate.Page_Load(Object sender, EventArgs e) +115
System.Web.UI.Control.OnLoad(EventArgs e) +106
Xtraction.Web.PageBase.OnLoad(EventArgs e) +17
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785
Based on the error information you provided, the reason I retrieved is that your application pool is not set up to use a service account, which prevents you from logging into Xtraction.
You need to set the application pool to use the Windows service account:
Go to IIS Manager > Servers > Application Pools > Xtraction
Click the Advanced Settings link in the right pane
Go to the Identity section, if it's set to Network Service, then click the ellipsis on the right
Change to "Custom Account" and enter your service account - this must have dbowner (or at least db_datareader and db_datawriter)
permissions on the Xtraction database
Click OK and restart the application pool (or execute iisreset). You should now be able to log in to Xtraction
For more information, you can refer to this link.

Session Variables Work in Chrome, Firefox but Fail in IE11

We recently upgraded a web server to Win2012 (from 2008) and started using ActiveDirectory. The main web site uses an external order form written in C# (ASP.NET 2.0). Everything was working fine in the old server until we migrated. Now I get errors when trying to read Session variables in IE 11 (everything works with other browsers).
This is the error I get with the line causing it:
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:
Line 974: private void WriteTextConfirmation ()
Line 975: {
Line 976: string sFolders_OrderForm = Session ["Folders_OrderForm"].ToString ();
Line 977: string sOrderNumber = Session ["OrderNumber"].ToString ();
Line 978:
Source File: d:\Web Sites\Order Form\SubmitOrder.aspx.cs Line: 976
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
SubmitOrder.WriteTextConfirmation() in d:\Web Sites\Order Form\SubmitOrder.aspx.cs:976
SubmitOrder.Page_Load(Object sender, EventArgs e) in d:\Web Sites\Order Form\SubmitOrder.aspx.cs:1189
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +41
System.Web.UI.Control.OnLoad(EventArgs e) +131
System.Web.UI.Control.LoadRecursive() +65
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2427
The problem is that the Session variables that are being read are null. They should be set in the Default form and passed for use in the SubmitOrder form. These variables work with FireFox and Chrome but fail in IE. I'm not sure why this would occur.
We had the same problem and setting the session state to cookieless in Web.config fixed our problem.
Since you are saying that it is browser-specific, it would have to be a setting with the browser. Maybe you have cookies turned off?
Update
I did some searching, and it looks like it could still be cookie related.
Session variable empty in iis7 application
Another common cause of this issue is when the server name contains
underscores (e.g. DEV_TEST). Underscores aren't allowed as host names,
and could interfere with the ability to set cookies.
This Server Fault question has a few answers saying the same thing:
https://serverfault.com/questions/178733/iis-7-0-does-not-keep-session-variables
And another SO question saying underscores:: IE8 does not keep Session Variables
More from Google: https://www.google.com/search?q=iis+application+session+variables+IE

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

NullReferenceException in Page_Load

I have developed my project in asp.net 3.5. It works fine in localhost, when i published in the web sometimes its working fine but sometimes i am getting the following error. I think some error while conecting to the server but dont know exactly. Please help me to do it fine.
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.] Result.Page_Load(Object sender, EventArgs e) +128 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +50 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Enable debugging in your web.config file (Debug="True") and turn RemoteErrors="On". This will provide a much more detailed error message so that you can find what is throwing the NullReferenceException. Once solved, remember to reset these configurations.
Check the code inside your Page_Load method, its throwing a null refernce exception
HTTP Request pipeline is giving the issue here not the page.
you need to check and trace HTTPContext here

'License expired' error when dynamically generating Excel docs in ASP.NET

Anyone familiar with error below? When I run my webapp to generate a dynamic excel doc from my local machine it works fine but when the same piece of code is invoked on the server I get the below error. It seems like it's a permissions issues since it works on my machine but not the server but I don't know where to start in order to pinpoint the problem. Any guidance/help is greatly appreciated!
Server Error in '/' Application.
--------------------------------------------------------------------------------
This command is unavailable because the license to use this application has expired.
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.Runtime.InteropServices.COMException: This command is unavailable because the license to use this application has expired.
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:
[COMException (0x800a03ec): This command is unavailable because the license to use this application has expired.]
Microsoft.Office.Interop.Excel.Workbooks.Add(Object Template) +0
PaymentsReport.Page_Load(Object sender, EventArgs e) +70
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
Office/Excel is installed on the server and I can open/save excel docs on the server. Could it be the version of excel on the server vs. my local machine? If so how can I make sure I have the latest on the server?
Apart from being installed, you need to make sure the application is activated on the server:
http://support.microsoft.com/kb/294973
Has details on how to do this.
Using Office Interop requires that the Office components you're using actually be installed on the server.
I'm gonna take a WAG and say that you just can't slap any old copy of Office on a server and let multiple users access it via your website. You need to look at the licensing restrictions for using MS office in a server environment.
Do you have a licensed, activated copy of Excel on the server? It probably works on your local machine because you have Office/Excel installed locally.

Resources