IIS Express doesn't keep session data - session-state

I have an application that I run in Visual Studio 2013 under IIS Express server. The problem is that session data is not kept between pages and I find with null objects that weren't null the page before. If I compile the application and deploy it on a web server with IIS it works normally, so it must be something with IIS Express. I searched the config files in the document folders, but really don't know what it is.
Thanks,
Luke
Edit 25/11: I'm debugging the code on the same machine witn VS 2013 and VS 2010 and I found where the code behaves differently. After the code behind has been executed and the page has been built, in VS 2010 the execution ends. In VS 2013 after the page has been built I get another call to the method context_BeginRequest(object sender, EventArgs e), which redirects the application to the starting page, where the instruction Session.Clear() clears the session. The problem now is: why is there this additional call to context_BeginRequest method? Why does it redirect to the starting page and not to the page it is currently in? Thanks, Luke.

I was having a similar problem. My code was running fine on a production server, but when I debugged it on my test machine, the session would be null between saving and redirects.
When I set the session state to cookieless, <sessionState cookieless="true", the session variable would be retained. This was undesireable though because it adds the session name to the url.
Upon further review, I noticed a line in my system.web <httpCookies requireSSL="true" /> When I commented it out, everything worked as usual.
The problem was that my production IIS server was hosting the code using https://, while my test IIS Express server was only using http. So my unsecure cookies were getting discarded.

Related

The WSO2 IS Management console url does not seem to be effective

I have a WSO2 5.10 server behind an AWS elastic load balancer. Per my original question How can I change the management console port of a wso2 is server using deployment.toml file changes , I modified the template and the server starts and correctly reflects the new management console url in the log file. When I log into it, it also indicates that I have logged in, but the browser simply redirects back to the logon page. Further, the original carbon management url is still active and functional. For example, logon.domain.com is the host name, idp.domain.com is the management url. Both display the carbon management screens, but the idp.domain.com url does not seem to function. No logs other than acknowledging the logon are apparent. This is a multi tenant setup, all of the tenant logons work fine
Any thoughts on diagnosing this would be much appreciated.

IdentityServer4 & Windows Authentication

I've been chasing this problem around for a while now and I can't get to the bottom of it. I've read the other solutions on here (https://identityserver4.readthedocs.io and https://github.com/IdentityServer/IdentityServer4.Quickstart.UI) and it's still not working, so I've tried to reduce this down to the absolute basics. This is not the actual problem I am facing, but produces the very same outcome. i.e. I can't get Windows Authentication to work.
I clone https://github.com/IdentityServer/IdentityServer4.Samples
I amend Quickstarts/7_JavaScriptClient/src/QuickstartIdentityServer/Quickstart/Account/AccountController.cs so that WindowsAuthenticationEnabled is true
I then goto http://localhost:5000/account/login and attempt to use the Windows external provider and I get 401.
The only difference with this simple sample here, and what I see on my actual system is that I'm getting challenged for credentials on my real site.
Debugging the code I never see if(HttpContext.User is WindowsPrincipal) succeeding, because it's always a ClaimsPrincipal.
Can someone explain to me what I'm doing wrong?
Do you have windows authentication enabled on your IIS site? This needs to be enabled for your WindowsPrincipal to be assigned. Note that windows authentication only works when running behind IIS or IIS Express.

__RequestVerificationToken always the same when reloading form in MVC4 application

While on a development server a standard MVC4 / EF4.5 login form with Html.AntiForgeryToken() refreshes its value with every page load. When deploying the same code on IIS the hidden value __RequestVerificationToken is always the same (at least in one browser session). Other similar applications on the same server do not seem to have this behavior.
Which web.config/IIS parameter might be responsible for this?
Already tried setting the machine key (single server) but this only seems to shorten the token, the refresh problem remains the same.
Also tested in different browsers. Here are some demo values for IIS and development server:
IIS:
Without machine key in web.config:
BGxqV7DjpHomi22By0r70WebHiWMV2OcsrCMN-dNDkRElZrv6BMQH23_zK9abmRsty_n1NImH2-gEsi3nBrWIQ2
With machine key in web.config:
dXBdht7mn2plT2rPvv0HzWtFvn-N9MT6xzW_xc8dVqnLdofzrL5v0SZFMAFPTANR0
Cassini / development:
Without machine key in web.config:
Yedkrxms9oYmHGzhV93qsrryVuNKZSWKBwCkP-RzK-tAZGgQ6J5g6Yp0LsCQPehucVwDcUs5lfRUf6Y6FxYUqY0olkE3-PmtF0ZnrCcbXD6XuA1PgPoFchreTPnCCSCwsh3E3FPmdKPlabyOfqiykkVqocxzYBMqd7A3bCZIxU01
With machine key in web.config:
iFjqi1OYplYfhCYdflAw1LSncVwK3b1yfDaJRgfrqVamucJ992D3-pFD__RolMZ_edp6muXQWLkxGOQp5Wn2ObTKXltO2J9tq32-JUMGu7cXdYZMkty3MRwuE-SuIFt7zo7TvQ2
Try the fix mentioned in the below KB. It solved the issue in our environment.
http://support.microsoft.com/kb/2656351

How do I get more details on my request error on IIS7

I have deployed a REST service on an external server (IIS7). When I start the service from VS on the Dev server it works fine. But on the server i get:
Request Error, The server encountered an error processing the request. Please see the service help page for constructing valid requests to the service.
How do I get more details on this error? I have looked in the log files directory that is configured under Logging feature for this web site in IIS Manager, but there are no files at all for this site it seems.
You should look in the Windows Event Log using the Event Viewer application (eventvwr.exe). Output to the IIS log files may be buffered so their contents may be updated after a restart, or when IIS is set to do it. Restarting IIS is a surefire way to force this.
Here is a blog post on how to do this.
I'm aware of 3 ways to get nicer errors:
Set UseVerboseErrors in InitializeService method. However, this won't give you anything if your error occurs before InitializeService is called (which happens).
Set IncludeExceptionDetailInFaults to true using an attribute before your service class.
Set IncludeExceptionDetailInFaults to true using web.config.

running a .net web service on iis6 deployed on windows 2003 server sp2

To whom it may respond to,
We have deployed a web service to Windows 2003 Server SP2 , .net framework 3.5 .
"The service is not running , we are getting the error :
The website declined to show this webpage
HTTP 403
Most likely causes:
•This website requires you to log in.
What you can try:
Go back to the previous page.
More information
This error (HTTP 403 Forbidden) means that Internet Explorer was able to connect to the website, but it does not have permission to view the webpage.
For more information about HTTP errors, see Help."
We have played around with the permissions but the situation didn't change a bit.
We would be very glad ideas on it,
Thank you for your concern,
Best Regards,
Kayhan YUKSEL
Make sure you have aspnet_isapi.dll as your wildcard handler in the Virtual Directory setup. Properties --> Virtual Directory --> Configuration --> Insert... --> aspnet_isapi.dll, make sure you uncheck Verify that file exists.