I've written a 2-tier C# asp.net application.
Everything works OK, but if I modify the SQL Server data using the management console, the changes are not displayed on screen. It seems the application reads the data from a cached instance.
I have tried everything to make sure it's not a browser cache issue... the data remains static until I restart the app or restar the web site. even clearing IIS cache doesn't help. If the data is updated by the application, it works ok... Any info about a default setting on the EF that caches data automatically?
I'm running Win Server 2k8 and SQL Server 2008, but the problem was there also for SQL2005.
I have no experience with this, but maybe the SqlCacheDependency can help you.
See this article for more info: http://davidhayden.com/blog/dave/archive/2006/04/29/2929.aspx
Related
I want to building a Blazor WebAssembly Progressive Web App, that can run offline.
I began Blazor this morning, and I'm just trying to get the hang of it.
To begin I want to do something like keep.google.com. You can work on you notes offline, on different devices, and when the connection is re-established, all notes are synchronized in the background with the server.
My idea is to have simple notes on a server, with an id, title and a message. These notes can be displayed and added/modified from the client. Since I want the application to work offline, I want the synchronization process to be as follows:
The fist time visiting the website, all notes are fetched from the server,
When notes are added/modified, they are saved on the server,
If connection is lost, notes can still be read and added/modified localy,
When the connection is re-established, the modifications are saved to the server,
Periodically or after pressing a button, sync is done between client and server to fetch new data present on the server.
I think the way to do this is to have a copy of the database localy. Client do modification on the local database and periodically/after pressing a button/when connection is re-established, I sync local database with server database.
I'm sure there is an official and easy solution to do that. I followed the CarChecker example from Microsoft, but they used the IndexedDB in javascript to do that (23min13 in the official tutorial video).
Do you know a .NET solution/tutorial/service that store data locally, and sync in the background with the server ?
I wrote a Blazor WebAssembly PWA with similar technical requirements. There is certainly more than one way to accomplish this but the steps I used are as follows:
I used sqlite on the client side to persitist the data locally. The simplest way to make that persist-able with the ability to use Entity Framework is to use the SqliteWasmHelper nuget package. https://github.com/JeremyLikness/SqliteWasmHelper
On startup and/or when online I fetch the necessary data and insert it into the local sqlite database.
The user can make changes and I save that to the local sqlite DB and mark it as ready to be synced.
I have a background service with a timer which executes on a configurable interval and grabs the local data marked to be synced and calls the API on the server to save the data to a SQL Server database. Of course I check to see that the user is online before attempting the sync.
I use Javascript to determine whether the device is online. I can provide that to you if you need but you should be able to google it.
I have an application update checker based on this method which works pretty well: https://whuysentruit.medium.com/blazor-wasm-pwa-adding-a-new-update-available-notification-d9f65c4ad13
I hope that helps. I'm happy to provide more detail if you like.
I have a web app written in ASP.NET Web Forms which takes like 7 seconds to perform any anction.
The browser tools says that the loading time is spent to actually send the request, while to retrieve it is fine.
Here are a couple of screenshots
How could I test what's wrong other that that?
I have other applications coming from the same source code, and those works fine.
The webApp is running on a local IIS server (8.5) using a classic asp.net 4 app pool and is made in Visual Studio 2010 (althought I could test it with 2013 also)
I scanned the whole thing using Ants Performance profiler
but I found nothing.
Anyway I found the cause were a really simple query which should've returned back a single line..
The db wasn't properly indexed so it took forever to load
Removing that query solved the problem for me
Thank guys
I am currently having a strange issue with sessions, I've worked with MVC for quite a while and never had this in previous versions. Currently making a new system using MVC5 for the first time, all is well. Sessions are being set with no issues, however, if I modify a cshtml file in VS my session is killed.
Also I have a file upload feature which works, but when you upload a file and then navigate to another page the session is gone again. This is working locally and also on a Windows Server box we use for sandboxing.
Has something changed with the new versions of MVC regarding sessions? I've never had this before. I've got it set to use in-proc sessions, never normally needed to change anything but I have for the sake of things used cookieless, used cookies etc as options. Nothing seems to work.
If anyone has an idea that would be great.
It is interesting that you haven't observed this earlier - as always when you update the contents of your web site, IIS could recompile declarative resources causing the restart of the app pool which effectively removes all session data stored in memory.
A solution would be to switch to other, persistent session storages, sql is possibly the easiest to configure. You just need a sql server where you run the script that creates the session database:
http://support.microsoft.com/kb/317604
Another option would be to use the State Server:
http://msdn.microsoft.com/en-us/library/ms178586.aspx
The performance of the State Server is usually better than the SQl Server as the data is not persisted onto the disk. However, since the state server is a separate process, your application server won't loose sessions even when the app pool restarts.
I've built a Compact Framework application to be used by delivery drivers. The system includes a WCF Service and SQL database on the server as well as a SQL CE database and CF application running on the mobile device.
Now the question is how to I update all this easily when I release new versions? The problems are:
it may be deployed to hundreds of PDAs
when first installed on a PDA the SQL CE database has to be populated. This can take a while. I don't want to have to do this each time the app is upgraded so I'm going to have to run scripts to update the db schema rather than just replacing the whole file and repopulating it.
the WCF service code will need to be updated
the SQL database schema will need to be updated
I can see solutions to all this but it seems like a lot of work. I thought it may be helpful to get a few tips before I launch into it all.
Thanks a lot
Mark
I think , you should divide your whole deployment in two phases
1- Client Deployment where you can upgrade your client ( PDAs + SQL CE )
2- Serevr Deployment where you can upgrade your Server side functionality ( WCF Service code + SQL Server database)
so these two phase must be independent of each other i.e. you can deploy both the phase simulteneously.
I ended up using WmAutoUpdate. Please refer to Automatically updating Compact Framework application code
I need to create a desktop WPF application in .NET.
The application communicates with a web server, and can work in offline mode when the web server isn't available.
For example the application needs to calculate how much time the user works on a project. The application connects to the server and gets a list of projects, the user selects one project, and presses a button to start timer. The user can later stop the timer. The project start and stop times need to be sent to the server.
How to implement this functionality when the application is in offline mode?
Is there are some existing solution or some libraries to simplify this task?
Thanks in advance.
You'll need to do a couple of things differently in order to work offline.
First, you'll need to cache a list of projects. This way, the user doesn't have to go online to get the project list - you can pull it from your local cache when the user is offline.
Secondly, you'll need to save your timing results locally. Once you go online again, you can update the server will all of the historic timing data.
This just requires saving the information locally. You can choose to save it anywhere you wish, and even a simple XML file would suffice for the information you're saving, since it's simple - just a project + a timespan.
It sounds like this is a timing application for business tracking purposes, in which case you'll want to prevent the user from easily changing the data. Personally, I would probably save this in Isolated Storage, and potentially encrypt it.
You can use Sql Server Compact for you local storage and then you microsoft sync framework to sync your local database to the server database. I recommend doing some research on the Microsoft Sync Framework.
Hello all I implemented this application I've created my own off-line framework
based on this article and Microsoft Disconnected Service Agent
DSA
I've adapted this framework for my needs.
Thank you for all.
you can use a typed or untyped dataset for offline-storage.
when online (connected to internet) you can download the data into a dataset and upload it back to the database server. the dataset can be loaded from and saved to a local file.