My web application in c# writes in a log file the tasks performed by the users.
Everything goes well as long as the number of users is small.
However, when there are many users working with the application, the writes to the log file fail because it is in use.
Is there a way to sequence the writes to the log file so that all user activity is recorded?
I know can use a database for writing log but i want to make it simpler.
Related
I'm needing to access files from a network share but my concern is more about whether reading the same file from the network share at the same time in multiple threads will encounter problems? I need to send back the file from the network share to the calling application in memory.
Will this lock the file whilst the given thread is reading the contents?
The code is a C# Web API application that returns files.
Thanks
Some more information
I have updated the apps application pool as the user that has access to the network share and it seems to work.
So here is my case, I want to create a web application using ASP.Net,
I have a simple UI that has two text boxes and a button called "RUN"
the two text boxes are for first and last name
a user can enter values and click run
I have a function that access Mongo Database and get all the documents where the first and last name match what the user have asked for
then I write the result to an output file "Excel sheet"
then that "mongo" function returns to the "Button_Click" function
which goes to disk and upload that excel sheet and give the user a save "window" so the user can download the file.
I have only tested this on my local machine and seems to be working fine, now I am not sure how that is going to work when I move to a different machine.
but that is not my question,
The question is, I want to add a third text box where the user can enter a location where he/she wants excel file to be dumped. that can be on a third server that is accessible from client and server "where web app is hosted".
the reason is that some queries can take up to 15 or 20 minutes and the user does not want his/her web browser to be running the whole time. so after specifying the info needed "firstName, LastName" along with the location where the excel file is going to be saved, he can click run and close the web browser. the program will run in the background I am assuming and dump the excel file to the specified location and send an email to the user notifying that the file is ready and was copied to the desired location so he/she can check it later on.
Is this doable? and how will the program be running when the user has closed his/her browser ?? do I need two different projects ?
The point is that you need to do an asynchronous call to some function on your server to do the work for you without letting the user wait on browser. For this you can write a WCF service with asynchronous service operation .The WCF service will be hosted under a windows service or IIS on a server, the implementation will include the functionality you want ( such as querying the db, creating excel file, writing the file on server and sending email), all these should go inside the WCF service implementation, and from ASP.NET you just click the button, you will grab the user input and call your asynchronous function asynchronously that is defined in your WCF service (via the contract that you will provide)
Read this for
How to: Implement an Asynchronous Service Operation
For that kind of long running process in ASP.Net, we normally use background task such as hangfire.
You might want to read How to run Background Tasks in ASP.NET.
I want to write C# windows application and save it on server.
This application shows message to user when request come to server.
For more explain, I apex web application on my server and I want to show me message when network user request that application and more explain,my apex program URL is this:
http://serverIP:7777/rafm/f?p=105:LOGIN:2771142526496053
And, when my local network user request that URL, on server C# windows application show me for example "ok" message,How can i write this purpose?thanks.
Short answer is: you shouldn't.
Server applications should be designed to run "headless", meaning without a screen or console. What would happen if your server is running without a physical monitor? Or without any user logged in? Who would see this messagebox? Who would dismiss this messagebox? If 1,000 users log in, would there be 1,000 messageboxes? That would be unmanageable. This is why server frameworks like ASP.NET or Salesforce's APEX don't even allow you to do that - they literally don't have a Messagebox.Show command available, because they're not running in the context of a windowing system.
What you need to do is simply write this information to a log - either a log file, Windows Event Log or any other logging facility, and then, if you want to trace login calls to your system, find them in the log.
I have an ASP.NET MVC website which clients post files to as part of an order process. These files can be up to 200MB. I have a need to transfer these files to another server via FTP. I don't really want to burden IIS with this. So was thinking of writing c# app to handle the file transfer which ran every x minutes and use windows service to run it.
Would this be an ok solution or is there something that could handle this for me already?
If I wrote the application should I let windows service handle the scheduling i.e. start the app every x minutes or should I just get it start the app on say startup and let the app handle the sleep/wakeup.
I was envisaging something quite rudimentary. Using SQL to track what needs uploading and has been uploaded. Are there any other considerations particular to a window service?
The website runs on iis8 on a windows 2012 vps.
One architecture tip -- use a simple executable and a scheduled task rather than write a service. You don't need to worry about memory leakage over months then.
You could probably implement this without writing any code -- you can script ftp.exe pretty effectively. I'd just script it to push all the files, and then, presuming FTP.EXE exited with 0, to clean out the uploads folder and rinse and repeat.
I have developed a desktop application that will be used without my presence. Therefore, my program may register different events - input, executed operations, working time. Is it possible to modify app for sending logs to any cloud for remote viewing reports?
I have accounts on Wuala and Google Drive, but not a problem to register somewhere else (DropBox? SkyDrive? I don't know what cloud will be easier for work in this situation).
Or you can suggest another, more elegant, solution.
I am using C#, .Net 2.0. Logs are simple .txt files.