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

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

Related

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.NET - Accessing Active Directory from code behind page

I have made a web application, which reads/writes from/to Active Directory. In my web.config file there is
<identity impersonate="true"/>
and
<authentication mode="Windows"/>
When I display
System.Web.HttpContext.Current.User.Identity.Name
in some label, it shows mydomain\myusername, so I think impersonation works.
Now to the question. When I access the application on the server, where the IIS web server is running, everything works great. But when I access the web application from a remote PC, I get an exception (the label still shows "mydomain\myusername").
I have traced the problem down. In the code behind when I call
Forest currentForest = Forest.GetCurrentForest();
the variable currentForest knows its currentForest.Name, currentForest.RootDomain or currentForest.ForestMode, but any call to currentForest.Domains, currentForest.Sites or currentForest.GlobalCatalogs results in
System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException.
Now I'm lost and don't know what to debug further. The account I'm using is member of Enterprise Admins (multi-domain forest). I have tried it on two different servers with different IIS versions (IIS 7.5 and IIS 6.0) with no luck.
And the thrown exception isn't of much help:
Exception Details: System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred.
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:
DirectoryServicesCOMException (0x80072020): An operations error occurred.
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +557
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_AdsObject() +42
System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) +98
System.DirectoryServices.ActiveDirectory.ADSearcher.FindAll() +46
System.DirectoryServices.ActiveDirectory.Forest.GetDomains() +543
[ActiveDirectoryOperationException: An operations error occurred.]
System.DirectoryServices.ActiveDirectory.Forest.GetDomains() +512484
System.DirectoryServices.ActiveDirectory.Forest.get_Domains() +44
myWebApp.ASPpage.Button_Click(Object sender, EventArgs e) in C:\Documents and Settings\myUser\documents\visual studio\Projects\MyWebApp\MyWebApp\ASPPage.aspx.cs:158
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
EDIT: If it is not obvious, I want to use currentForest.Domains to search the whole forest (all domains) for a user given by UPN name.
I found the answer to my question in one of "Related questions" on this page. The answer was in this topic: Why does DirectoryServicesCOMException occur querying Active Directory from a machine other than the web server?
I found, that it was exactly my case. After reading the suggested Microsoft article, I learned, that impersonating works only for local resources on the IIS server. To access network resources (SQL, Active Directory), I have to set "Trust this computer for delegation" in the computer object in Active Directory.
It was because the IIS always authenticate therefore System.Web.HttpContext.Current.User.Identity.Name showsmydomain\myusername; to verify that the impersonation works you could use:
System.Security.Principal.WindowsIdentity.GetCurrent().Name, also the System.Security.Principal.WindowsIdentity.GetCurrent(true) returns null when it is not impersonating.

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?

IIS7 giving Object reference not set to an instance of an object error

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.

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

Resources