I deploy my application .NET application IIS server and i try to use Single sign-on service
but the time when i see the SAML request is wrong time-zone
<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
ID="XX"
Version="2.0"
**IssueInstant="2023-01-23T06:14:45Z"** HERE THE ISSUE MUST BE +3 H FROM THE TIME ZONE
Destination="XX"
AssertionConsumerServiceURL="XX">
<saml2:Issuer>XX</saml2:Issuer>
...
i check the time on the server is correct
Picture of time in server
i went to the server and change in services (windows time) to auto
windows services time
write time zone on SMAL request
Related
I am from west India. DateTime.Now returning current time when debugging from Visual Studio. But when I hosted it on an Azure App Service, it is returning 6 hours earlier time. The App Service is hosted in West India. I added App Setting for the App Service WEBSITE_TIME_ZONE to Indian Standard Time and restarted the App Service but still the same issue.
Indian Standard Time is not supported as App Service's timezone name, check supported time zone names here (Check exact spelling of the tz name in left-side column).
Best practise is to use UTC time in server context and convert it to local time in UI.
Azure server times runs on UTC by default. This way you could calculate the difference from the user time. There is also the option to use DateTime.UtcNow()
I ran into an issue with an application running in a remote location through a Citrix server. When the application was run in a remote location it logged an event to the database with the time from the remote location even through the user was accessing the application through Citrix.
Did .NET's DateTime.Now somehow "escape" the Citrix container and find the time of the remote machine or is there some other explanation?
Here is the current setup of the application.
The application logs events to a database in the US
The remote user is located in Europe and access the application through Citrix which simulates running the application in the US
The Citrix server machine time is set to the US time
P.S. The application has been updated to query the time from the database when saving in the future.
A few things:
Citrix's "time zone redirection" feature is probably the explanation for what you've observed. The details are specific to what particular Citrix product you are using (which you didn't supply). You may be able to disable that feature. Google it, or ask on ServerFault.
Really, you should avoid using DateTime.Now in server-based applications. It should be irrelevant what the server's time zone setting is. Use DateTime.UtcNow, DateTimeOffset.UtcNow, or DateTimeOffset.Now, along with the TimeZoneInfo class, as appropriate. Alternatively, use Noda Time.
To answer the question in the title, you can see the source code for DateTime.Now here. It works as follows:
Call DateTime.UtcNow, which itself calls the GetSystemTimeAsFileTime Win32 API. This is the system clock. It is in terms of UTC - not any specific time zone. If you're running in a VM, typically this system clock is synchronized with time from the host.
Get data about the local machine's time zone. It uses a truncated version of the complete time zone (for performance reasons), and it caches the data for future reuse.
Note that if Citrix is redirecting the time zone, it will affect this step.
Using the data retrieved, calculate the offset from UTC - for the specific UTC point retrieved in step 1.
Apply the offset to get local time, truncating if MinTicks or MaxTicks are exceeded in the conversion.
Mark the value calculated in step 4 with DateTimeKind.Local, and return it in a DateTime struct.
I've been doing some research around on how to properly store and save the Date and Time in a Web Application but I couldn't find a post that has a marked answer.
I have a ASP.NET MVC website and I use C# for backend code and MS SQL for the database, let say you have different client with different TimeZone currently I'm storing the DateTime by DateTime.UtcNow and I just display it back in "YYYY/MM/DD" format.
All you really need to do is make sure the application server and the database server share the same time settings and are in sync.
IIS, .NET, and SQL Server all use the system time by default.
Clients in different time zones will still use the system time of the IIS server they are connected too. Most sites just format the date on the client side, to the clients zone.
If you want to get fancy, you can write database triggers that handle transaction time stamps. This comes in handy if you do a lot of back-end processing.
I have database and mvc application hosted on iis. I periodicaly gather data from internet and save them in sql database. And i calculate statistic and graphs from these data and publish them in mvc application.
Problem is that iis have recycling period about 1 hour -> meaning that my timer(function) which gather data from interenet is stoped whenever there is server restart, recycling or there is no request on the web page.
solutions i have found are:
turn of recycling - i don't own srv can't do that.
windows service - 99% hostings don't allow host ws...
So is there any solution, service, framework, which purpose is to gather data and i can be sure that it will not stop after some inactivity time or server restart? or is my logic completely wrong and i need to gather data diferently? can it be done on hosting which i don't own? can it be done using iis?
can it be done using iis?
If the IIS in question has app fabric installed, then that supports an auto start feature, which effectively lets you write 'service like' code which will keep running in the background.
Quick overview here
I am creating a .NET service that gets timestamp information (in the local server time zone) from another Windows 2008 server. I don't have control over the other server, and I need a way to programatically get the timezone offset from that server so that I can interpret the timestamp information as a time in UTC. Is there a builtin service to get the time (and timezone) from a windows 2008 server? Thanks.
Check out this post: http://blogs.technet.com/b/heyscriptingguy/archive/2012/03/28/use-powershell-to-see-time-zone-information-on-remote-computers.aspx
It discusses using powershell, you may need to have access to the server, but perhaps it will help if your looking for a way to access programatically.
If you are able to map to the server, you could also try:
net time \\SERVER_NAME