on 2015 Mar 07 8:25 PM
Hi, I am encountering NullReferenceException and other exceptions when making calls Membership and Role provider functions in a .Net MVC Web application using SQL Anywhere. Most often I am seeing the errors when calling the Roles.IsUserInRole() function however I have also seen them when calling other functions such as Membership.ValidateUser(). The errors are only occurring when the web application is being used by multiple users (i.e. it is under load) The errors are ultimately causing the IIS worker process to hang, rendering the web application unresponsive until such time as it is manually reset. I am using SQL Anywhere 11.0.1.3113 however I have also produced the problem with SA-12.0.1.3152 and SA-16.0.0.2043 Developer Edition which I downloaded a couple of days ago.
I have been able to reproduce the problem in a test environment using a simple web application and load testing software. The steps I have taken to produce the issue are: * Create a new MVC3 Web application in VS 2010 * Include a reference to iAnywhere.Web.Security * Add Connection string and membership/role provider details to web.config * Add a Call to Roles.IsUserInRole(String username, String roleName) to the existing sample pages * Deploy the application and place it under load of at least 2 concurrent users. (I am using Fiddler with the StresStimulus plugin for load testing)
Here is a typical stack trace for the errors that I am seeing:
iAnywhere.Data.SQLAnywhere.SACommand._ExecuteReader(CommandBehavior commandBehavior, Boolean isExecuteScalar, Boolean isBeginExecuteReader) +1388
iAnywhere.Data.SQLAnywhere.SACommand.ExecuteDbDataReader(CommandBehavior behavior) +129
iAnywhere.Data.SQLAnywhere.SACommand.ExecuteReader(CommandBehavior behavior) +130
iAnywhere.Web.Security.SAConnect.CallStoredProcedure(String procedureName, SAParameter[] parameters, Boolean suppressException, Hashtable outParameters, ArrayList readerArray) +1669
iAnywhere.Web.Security.SARoleProvider.IsUserInRole(String username, String roleName) +377
System.Web.Security.Roles.IsUserInRole(String username, String roleName) +794
ASP._Page_Views_Home_Index_cshtml.Execute() in c:\\web\\WebTest\\Views\\Home\\Index.cshtml:8
While the NullReferenceException is most common, I have also seen AccessViolationException, SAException (0x80004005): Connection was terminated and others, all with similar stack traces.
Can anyone tell me why these errors are occurring and how I can avoid them?
This sounds like a job for the technical support team. Have you considered contacting them?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are a number of steps to setting up SQL Anywhere to be used as a DataSource for the management and control of memberships and roles for your ASP.Net application, and you may be suffering from a missing step or a misconfigured/misalignment of some of those.
It is possible you might just not have the schema required to back up the roles ... so make sure you have installed those into the specific database being used for this by running the .\\Assembly\\V2\\SASetupAspNet.exe -c "connection string".
It is also possible your registered connection string is just not connecting to the same server and database as used in that step. There are many ways where your connection string could be generic or not specific enough to find the same databasename or servername so you should spend time here. [Tip: If using DSNs for this do be careful to create them as System DSNs since IIS is running as a Windows service and won't normally see any user DSNs.]
It is also probable that the database is not actually running, so you might want to launch the database server as an Automatic Windows Service.
It would seem you may have registered the Roles Provider already (going by the backtrace) but revisiting that part of the setup (for all the providers you installed schema for via SASetupAspnet.exe) may help identify if you missed anything there ... and similarily review all the steps for this (ie. the links at the bottom of the SQL Anywhere ASP.NET providers page)
And finally, I don't consider myself and ASP.Net expert so (caveat utilitor) ... and if you need any more help than this do consider Jack's earlier recommendation.
HTH
User | Count |
---|---|
75 | |
10 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.