Forms authentication and server time - c#

I have a server that gets it time reset to 7 hours in the past. When this happens forms authentication no longer works.
When I resync the time with the server time it works again.
What could be causing this? It is actually and issue for me more so then changing the time, because I don't think it will be possible to keep all the clients and the servers in sync.

You can't have a production server with jumping time. Google "Windows NTP time synchronization" to find how to easily configure your servers to always be within microseconds of correct time.

Related

ASP.NET Application Gets Slower Over Time

I'm running a .NET C# (4.5) web forms application and on our production server, the application gets slower and slower for everyone over time until about an hour where it becomes pretty much unusable and we just restart the server.
It works perfectly fine on my local machine. Never gets slower at all. So I'm trying to think of what would be different.
My local machine connect to the same database. There's also some active directory things being used for logins but that also connects to the same place on both my local and production environments.
I have debug off in the web.config. I've also looked up pretty much any other solutions and haven't had luck.
I did see some stuff about viewstates building up with ajax requests. I do have a page with updatepanels that are refreshing every few seconds, but I'm confused as to why the production server would be getting slower over time with this and not my local machine testing.
There's only about 10 people using the application at the moment also. Any ideas?
Refreshing a bunch of updatepanels every few seconds is not a good idea pretty much. I was able to optimize things here and there but in the end it was the auto refreshing that was slowing things down. Completely reprogrammed using signalr to grab updates and now it's very fast.

ASP.Net Timeout issue

I developed a medium sized asp.net website that accepts several hundred pdf documents a day. I have a very simple insert SP that inserts the documents into an Image field in SQL Server 2008 R2.
A few times a week I am starting to have an issue where my website seems to be timing out on this insert. Its very strange cause my drop down lists still load and authentication still works. Most of the time I can recycle the application pool or restart IIS and that fixes everything.
That is a very simplified version of course but thats the long and short of it. Has anyone else had an issue like this ??
Thanks!!
Specify the maximum pool size:-
If this doesn't work, set the command timeout to 0. Please send us the exactly error message if the two above solutions don't work

All Application Pools time out, but not one

I am debugging in Visual Studio 2010 with IIS 7.5. I have four enabled AppPools. This is on my development machine, so no one else accesses it, at all.
So the problem is that three of these AppPools time out, but forth one doesn't. I am not bothered why this one stays there, but more concerned why the other three time out, as I use them more often.
I have checked all settings for them and they match exactly. I can certainly increase "Idle Time-out" settings but wanted to know what is causing it.
Thanks for your help.
Disable pinging (set Ping Enabled to false). When it's turned on, IIS hosting proces checks constantly (every 30s) if a pool process is alive. If a given application pool process does not respond withing a predefined period (Ping Maximum Response Time = 90s) it is restarted. I can't tell exactly why one pool is not restarted - maybe while debugging it was responding to IIS pings.
I couldn't figure out the reason. But as a workaround, I set "Idle Time-out (minutes" property to 60 and it is working out for me.

where does datetime get its data from asp.net / c#

I was wondering, where does
DateTime.Now;
get its data from?
does it get the data from my desktop? actually it does when i'm observing under debugging. I changed my desktop time back an hour, and the datetime.now gave me the exact same date/time.
My real question is, will this still apply when the project is deployed? Will my site continue to fetch time from the users pcs?
The reason for this question is, because i will be using session variables, which i want to dispose after x minutes. And if datetime.now gets the time from the users computer, then it would be a kind of a security issue.
Thanks in advance for your answer.
ASP.NET runs at the server. It is getting the time at the server. Note that during development, the server often happens to be the "user's PC", but that is coincidence.
Your analysis is both right and wrong. DateTime.Now would get the time from the machine where the code is running on. I assume that you have that piece on ASP scripts, that would be running on the web server when you deploy them. So the time would be of the web server rather than user's PC.
You could get the time from User PCs through client side scripts; like JS.
You need to keep your server Date correctly. As your code will run on server you will keep on getting the correct time. Changing the client machine date won't affect the server time. All your code behind (server side code) will get the correct time.
In asp.net or c# DateTime.Now shows time of server where the application is running.

Options to communicate to a C# desktop app from a linux server?

The desktop application is being developed with a demo version that is supposed to run for a few minutes and after that would request the user to restart the application to run again (the user has to input their login and password to access it), since I dont know much in this field the way I can think of doing this without the user bypassing it would be having a realtime communication between both or something of the sorts.
After X minutes the server sends a
message to the client to close/disable
the client requiring the user to
restart it, it also limits the daily
usage on the demo for the same user.
As I am very inexperienced in this type or communication I would like to consult you guys with what options I have here ?
The desktop application is developed in c# to run mainly on windows OS as for the server we only have linux available and as to what sort of service, if it is possible to make a webapi or session in php or perl to work with it that would be reliable enough would be nice but if that is not possible we are open to hear other options.
PS: If I have'nt given enough information or am missing anything important here please drop me a comment i will update as soon as possible.
I'd give a go to HTTPS with mutual certificate-based authentication as the safest option. The desktop app can poll the server (=ask periodically) and quit in case of no response / no connection / negative reponse.
However, based on the type of app you are developing and the target audience, you can expect an important amount of users to have connectivity problems or have no connectivity at all.
Because of this, at the end of the day, you can come up with a lot simpler solution, like measuring run-time locally without any server involved, and gain pretty much the same effect.
I don't think you need to involve a server to do this.
Just have the desktop application save the date and time when it started. Periodically on a timer you can check the current time, and see if too much time has elapsed for the demo version, and tell the user they have to quit.
It is very unlikely many users will try to get around this. They are more likely to dump your trial software in favour of something that treats them decently!
Checking DateTime.Now could work as Ben stated, but you'd be better off with System.Timers.Timer. Set interval to be your desired interval between auth calls in milliseconds. Attach a handler to the elapsed event that asks for auth info. System.Timers.Timer works in a separate thread so you can take advantage of some parallelism here. Changing the system time shouldn't have any effect on System.Timers.Timer but I am not positive on that point.

Categories

Resources