Asp.net Session Expire soon on live Web server - asp.net

I am facing a problem about web application,
I have lost session too soon
, I have already set timeout and that related things.
it is done when I have uploaded it on
LIVE SERVER
, after spend some time I not able to use session, it redirect me on Login.
Please tell me what i can do?
Thanks

Sorry i have to reply as answer not comment ,
Type “inetmgr” in run window to open IIS
from left pane “Connections” select your application.
right click on your application and refer the image to open “Advanced Settings” of application(to check which ApplicationPool is referred by application )
from “Application Settings” window you can see the Name of ApplicationPool. like Asp.net V4.0, DefaultAppPool, Asp.net V4.0 Classic.
Right click on the ApplicationPool that was assigned to your Application and click on "Advanced Settings...."
in the popup window ... check the Idle time out for ... that cause the timeout while web application is idle.

There're multiple ways why ASP.NET session state can be lost. The most common one is when the application pool recycles. This, in turn, can be due to IIS configuration (scheduled recycles), changes to the /bin folder or web.config file (can also be an anti-virus software that "touches" the files).
In case the session state is maintained using cookies, there can be situations when the browser doesn't accept them (and therefore, doesn't pass them back resulting in a new session created every time). You can verify that the cookies are sent (and that the value is not changing within the same session) by using Fiddler or F12 tools of your choice (the name of the cookie is ASP.NET_SessionId).
You may also check the sessionState configuration element in your web.config file to make sure those settings are correct (more on the subject: MSDN article).
Also, check the Event Log ("Application" log where the "Source" would be "ASP.NET X.X.X.X" where "X.X.X.X" is the framework version). In cases like this, there's usually some useful information in there.
Hope this helps.

Related

ASP.NET website shows 503 Service Unavailable after successful publishing

Every time I try to publish a website, it runs fine but when the website opens up it gives me a,
"HTTP Error 503. The service is unavailable."
Everywhere I look on the internet talks about it being my application pool but that seems to be running fine. I think it may be my web.config file but I'm not entirely sure.
PLEASE can someone help me.
"PICTURE OF ERROR BELOW"
Make absolute sure the App Pool is running
Goto WinKey+R (Start > Run) type in InetMgr, press enter.
Left side, Connections, expand your computer or the server in question.
Select Application pools.
Start all pools that have their "Status" as Stopped.
Make sure the site is set to the correct pool
Not all sites are assigned to the default application pool, in this case, in the left side expand sites, find your site, expand it. In the right column, click Basic configurations.
Edit the application pool there, go back to the first block and make sure your newly assigned Application Pool is running.
Test it
Select your site again, In the right side, there is a Browse site group, click on Browse *:80 (or something like that, this should do it).
Check permissions on site's folder.
Go to your site folder and give full permission to NETWORK SERVICE.
Make sure Application Pool service is not disabled in windows services.
If everything else fails, go to Services.msc and set the service related to your app pool to Automatic (maybe you or someone disabled it for some reason, who knows).
Reinstall IIS
Go to Control panel > Programs and resources > Install Windows Resources, find everything related to .NET, ASP.NET and install. Check all leftover boxes from IIS and subselects.
If this fails, uninstall it completely then install it again.
Let us know if any of these work.
This is most times caused by Application pool which has been disabled or because the application pool identity is invalid.
Go too IIS > hostname > Application Pools (Observe the Application is stopped)
Right click and go to Advance Settings
On Identity Select an Identity Pool from the drop-down list (possibly change the identity already selected by default)
Restart the Application pool
To set up an Identity Pool to select from follow this link

System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0

Firstly, I am aware this problem has been dealt with before here, and the solutions are always corrections to the connection string.
However, in our case, the connection string is correct, because most of the time it works fine. What happens is at some point the site 'stops' and starts logging this error. Simply recycling the app pool clears it, and everything is good again until the next time. A site might run fine for hours or days, but then it falls over and every request logs this error.
Since it is a transient error, I suspect it is somehow memory or service related? Either some kind of service that handles the connection from the ASP.NET site fails within the app pool, or there is some shortage of memory so whatever process is required to handle the connection fails.
It is not just a single server, I have seen this issue occur on various customers' servers, so I don't think it is some obscure glitch with a particular server. I have also seen sites that were running fine for a long time start to experience this issue (which suggests to me it is related to resource availability).
For the sake of completeness, this is the connection string from a site that exhibits this problem:
<add name="SQLConnection" connectionString="Data Source=localhost\sqlexpress;
Integrated Security=True;Initial Catalog=databasename"
providerName="System.Data.SqlClient" />
But like I said, this works absolutely fine for hours/days, until the problem occurs.
Just surfing with error message and got one link from Microsoft.
Seems to me like your problem.
Can have a look on this.
http://social.msdn.microsoft.com/Forums/en-US/9f191038-dbf6-4306-8f66-ec211a1e933a/format-of-the-initialization-string-does-not-conform-to-specification-starting-at-index-0?forum=adodotnetdataproviders
Thanks
Can you please check following points:
Make sure the account has full permission (both read and write) on folder:
"C:\INETPUB\WWWROOT\BE SITE WORK(FINAL)\4SIGHT\WEBSITE\BARAMATIESTATES\BARAMATIESTATES\”
I recommend that set “C:\INETPUB” folder allow all user access and edit, at least give full administrator right to IIS account.
2 Make sure IIS account is sysadmin of SQL Server.
Setting IIS Permissions for an Object
You can set permissions for any object in IIS, including Web sites, folders, files, and scripts. To set the permissions for an object in IIS:
Log on to the Web server computer as an administrator.
Click Start, point to Settings, and then click Control Panel.
Double-click Administrative Tools, and then double-click Internet Services Manager.
Right-click the Web site that you want to configure in the left pane, and then click Properties.
If you want to set the permissions for a Web site's home folder, click the Home Directory tab.
If you want to set the permissions for a folder in a Web site, click the Directory tab.
If you want to set the permissions for a file or a script in a folder, click the File tab.
Click the corresponding permissions that you want to set for the object.
To turn on script processing for a Web site or folder, click Scripts Only from the Execute permissions list.To turn off script processing, click None.
Click OK.
if the issue still persist let me know :)

Losing Session information after publishing an ASP.NET Website on IIS

I'm a beginner in ASP.NET 2.0.Probably this could sound too basic and stupid issue for someone expert in the ASP.NET.But this is giving me sleepless nights.
Basically i have developed a simple multilingual website with a master page and content pages which fills inside the content place holder portions of the master page. The application works great when it is configured to run on the ASP.NET Development Server 2.0. But once i publish it to run on the IIS web server it will no longer function. :( I could see from the trace that none of the session variables i use are stored and redirected to the relevant content pages.
Although the contents are displayed, the session variable values by which i take some decisions on the redirected pages are lost and i run into exceptions.
Please guide me where am i going wrong and exact procedure for Publishing an application.
Ex: my home page has URL which runs something like
http://localhost/Onlineupdate/Home.aspx?vers=1.1&lang=fr-FR
Based on the above URL, i strip and save the vers and the lang variables in a Session variable. However these are lost when hosted on IIS.
There are a dozen or so things that could cause the session data to be lost:
IIS restarting
The app pool restarting
due to a change to the web.config
due to a change to anything in the \bin directory
memory limit reached, or a bug causing the app pool to reset.
several other possible causes
Your host is actually a web farm, and you're using in-process memory, which will cause issues when one server fails over to the other, unless you're using SQL Server session state mode.
Since we don't have enough information to answer exactly what's happening in your specific situation, I'd ask you to start by reading up, starting here: http://msdn.microsoft.com/en-us/library/ms178581.aspx
Edit: I did find this blog article, which may be helpful: http://blogs.msdn.com/b/amenon/archive/2007/08/21/troubleshooting-session-loss.aspx
The following is not necessarily part of the answer, but added to try to be helpful.
If it's feasible, from my own personal experience, we've had success in eliminating our lost session issues by using the SqlServer Session State mode. Since we implemented this, our session issues have all but disappeared.
also i found the main problem that you should initialize session before use
like:
session[“id”]=””;
and after that it well work fine
In order to prevent this to happen first in the web.config set restartOnExternalChanges to false.
Now in web.config changes must be propagated manually(this means that the dev is now responsible to build a mechanism for config change propagation).
Hint: You can use file watcher for this that will listen for the web.config (or any config you use in you web. app) for changes and wrap it as a watchable configuration so you can reload the configs when they are changed.
Hope this helps
I faced the same issue in my ASP.NET MVC website .
and i have resolve it by next steps :
open IIS Manager
go to the application pools
right click on the application pool which related to your website
click on "Advanced Settings"
set "Idle Time-out (minutes)" to be "20"
set "Maximum Worker Processes" to be "1"
Click Ok to close the window
these steps has resolved my issue.

IIS logging feature

I have ASP.NET pages deployed and I was told that it appears to be logging quite a bit on the server (Ex. post and get). I am sure this is a feature on the IIS not with the pages.
The site interacts with other systems and use by a lot of users.
My questions are:
1. What does this mean?
2. Can I turn off this feature on the server?
Thanks.
1) Logging is a feature which you use to configure how IIS logs requests on the Web server.
2) Yes you can Disable logging from IIS by selecting Logging icon and disable from context menu.
I think it's frustrating that logging is turned on in IIS by default. If you don't know it's there, it's just filling up your web server with useless information.
However, the information in the log file is not useless if you know it is there.
If you have access to the web server, there are a couple of places that the log files might be saved in:
C:\WINNT\system32\LogFiles
C:\WINDOWS\system32\LogFiles\W3SVC1\exyymmdd.log
You can view the file contents in Notepad.
To get the exact log file name in IIS, right-click on the website, go to the Web Site tab, click on the Properties button, and go to the bottom of the pane. The filename is there.
There are choices of what kinds of data get logged. You may not need a lot of it. For example, the default log items like Date, Time and Client IP Address might be useful. Not so much Bytes Sent, Time Taken or Referrer, unless you are troubleshooting.

Changing IIS 6 Application Pools for a Web App Project

Following recent hardware problems, I attempted to switch a couple of our websites to use new, individual application pools. A test run on our staging server worked fine, and has had no visible negative consequences.
Unfortunately, trying the same operation on our live machine left one of our key applications struggling - my best guess is with some kind of mismatch in Session state. I could log in fine, but a few clicks later would be presented with a screen that was part login screen, but with all menus visible. This indicates to me that part of the system thinks the session had been lost (redirect to login page), but IIS itself had not lost the session (hence the menus showing on the master page).
I tried recycling all the Application Pools (new and old), and each website using IIS Manager. I also tried a single-space change to the web.config file, and a full release of the dll's. Still, I could intermittently use the system for a few clicks, do some useful stuff, then maybe find myself at a login screen again or similar. We have some logging and on some occasions I could see that the session was being timed-out after a couple of seconds, substantially less than the settings on the App-pool (default 20mins).
As soon as I switched the web site's app-pool back to the default, everything was ok again.
What have I missed? Any suggestions gratefully received!
EDIT:
Just thought... on the staging environment I did name the App-pool differently from the website name (e.g. Xxxx_Dev, Xxx_Test etc) but on live I just called it the same name as the website. Could this cause an issue?
do your various applications all use Forms Authentication? Have you specified unique path attributes in each form tag in the web.config under the Authentication tag?
OK. I think I've found the problem.
I was actually using an Application Pool that had been set up by someone else - of the expected name - but they had set it up with the Properties, Performance tab | Web Garden option to use 4 worker processes. I have now changed that to 1.
As the session state was being stored 'In Process' (the default), each time the connection hit a new thread it also essentially lost any stored session variables, as I now understand things.
Its early days, but a simple switch to the newly altered Application Pool (no restarts or web.config saves necessary thus far) and everything appears to be behaving normally.

Resources