We have a web application use sessions InProc to store large amount of data like datasets etc.
We are thinking about changing sessions state from InProc to Sql Server, but we are using Sessions at so many places in the code and it is very hard to find. (application is too big).
I did make classes [Serializable], but there are some serialization errors occured. WE catch all the errors using Global.aspx by Application_Error, but it is hard to figure out where in the code or which element failed, so i can fix it. I am thinking is there any way to know this information.
I am using vS 2010.
Thanks,
Check the Call Stack in the visual studio.
Debug --> windows --> Call Stack
Session is not the right place for big data like datasets. On every request it get deserialized, so big data results in bad performance.
Related
I have to use a bulk amount of data through out the session for each user in MVC application (data is user specific)
Below are the two method I found it
Use a session object load the data into it and retrieve when ever needed
Create a XML file into the disk and retrieve the data when ever required
which one of the above is good for a web application?
If both are not good please let me know a convenient method.
I read about caching but that also take the memory concern as Session or not?
Please help me with simple example if anyone has gone through the same.
I will not go with any of the approaches you highlighted, both the approaches will give you problems and code modification will be required when you plan to scale you application and try to move to load balancer or web farm type of environment.
You should try to make your application as much stateless as possible.
You can store the data in database, if your tables are properly indexed it will not take much time to fetch the data (almost same as fetching data from a xml file).
If the data is not sensitive and you requires it in client side only, you can think of storing it into sessionStorage
I am having an issue with an internal site during testing ( 50 + users).
the pages work fine with 1 or 2 users but when a bunch of peoples hit the site, I get errors for a lot of my data bindings "System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name ".
all these property names exist in the results I return from the database. but for some reason it happens with a lot of users at the same time.
I am using asp.net 4.0 and WCF.
The pages use data repeaters to bind data. i aslo checked the database and the responses from the database server are good, no issues there, so its purely application problem.
any help is much appreciated.
It seem there is a performance issue.
You can:
1.Use the simpler data source
2.Use output caching or partial caching
3.use data caching in your business logic layer ( like asp.net internal cache or Application Block Cache Helper , ... )
4.Review generated SQL by ORM(Entity Framework) and optimize it.
Use a really basic databinder, like SQLDataReader. It seems to me that you have some resource issues. And ensure you close all your connection strings.
I am developing a web application on ASP.NET with c#, when a trace error occurs on the website I store the error in a database from the global.asax using the Application_Error method. This is working fine but there are many errors occurring like client disconnected. How can I handle this error from global.asax it will not be stored in the database?
Assuming you don't want to track them at all, I would suggest creating a black list of ignorable exceptions and compare against them using the type and partial message text as the comparison. The black list could be stored in a DB table that you just read on ApplicationStart and cached or you could just hard code them.
You could also extend the solution by storing a count of how often these blacklisted exceptions are getting caught and store them in the application cache. Then have an admin page that could list the count or average frequency etc. in case you need to diagnose if these exceptions are actually occurring due to something valid that should be looked into.
It all comes down to how important these exceptions are to you and if they do become important in the future, how easily you can diagnose the issue with what tools you have at hand.
Over the last few months I have been developing an application using Entity Framework code first and sql server CE for the first time. I have found the combination of the 2 very useful, and compared to my old way of doing things (particularly ADO.NET) it allows for insanely faster dev times.
However, this morning me and some colleagues came across a problem which we have never seen in any documentation regarding SqlServer CE. It cannot handle more than one insert at once!
I was of the opinion that CE may become my database of choice until I came across this problem. The reason I discovered this was in my application I needed to make multiple requests to a web service at once, and it was introducing a bit of a bottleneck so I proceeded to use a Parallel.Invoke call to make the multiple requests.
This was all working fine untill I turned on my applications message logging service. At this point I began to get the following error when making the web requests:
A duplicate value cannot be inserted into a unique index. [ Table name = Accounts,Constraint name = PK__Accounts__0000000000000016 ]
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.SqlServerCe.SqlCeException: A duplicate value cannot be inserted into a unique index. [ Table name = Accounts,Constraint name = PK__Accounts__0000000000000016 ]
Strange I thought. And my first recation was that it must be something to do with the DbContext, maybe the DbContext I was using was static or something else in my Repository class was static and causing the problem, but after sniffing around I was certaing it was nothing to do with my code.
I then brought it to the attention of my colleagues and after a while it was decided it must be SqlServer CE, and after us all setting up different test projects attempting to recreate the problem using threads it was recreated almost every time, and when using Sql Server Express the problem wasn't ocurring.
I just think it is a bit strange that CE cannot handle something as simple as this. I mean the problem is not only with threading - are you telling me that it cannot be used for a web application where two users may insert into a table at the same time...INSANITY!
Anyway, just wondering if anyone else has come across this late into a project like me and been shocked (and annoyed) that it works this way? Also if anyone could shed light on why it is limited in this way that would be cool.
It looks like a bug in SQL CE. See http://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=641518
Hi
I working on Asp .Net project(Web App).
I have to many values, properties and fields. In order to use them I need to save them in somewhere.(I know about Session, Application and Cookie).
application isn't good cuz it is same for all user's but session is better(I need these values in server-side). Also cookie isn't good and I won't use that for security problem.
Session is good but if I use session a lot I must pay for massive memory on Host-Server.
So is there any better place can hold them ?
Edit 1
For more Information recently I fetch these values from database (so I won't to save them in database). and also use Wcf service for get these values from database. I want to hold these values to use them (for example sending them for service-method to do something or do something visually in page).
Thanks All
As has been commented, there are many ways of implementing state management, depending on the amount of data your looking to persist, overall volume of traffic, hosting costs, maintainabilty, etc.
This MS link describes the pros and cons of some of the techniques.
Yes, Session is the best way to use. Actually its consumes the comparatively least memory of all while using the server side state management technique.
If the values are much higher than you can use to store those values in database with the sessionid as the key with them. So that it will consume some what less memory from the server.
A database could be a good idea. Maybe SQL Server Express or SQL Server Compact Edition