5

I have a web application that is created using asp.net webforms template. It uses Asp.net Identity for login process. To make identity use my database i changed default connection string to point my own database.

I did not make any remarkable changes to the default template of asp.net webforms application.

I published my web site and add it to IIS sites. Now i can reach my website by writing http://myip to my browser. However after a while has passed my login page begins to not working. When i login with my correct username and password it should redirect me to the page i try to reach, but it behaves like i have not logged in and brings me the login page again with form is reset.

It is just like i am reloading the login page instead of loging in.

When i reset my application through IIS i can login as usual. It works correctly.

What is the problem?

Why my login page sometimes work and sometimes not? Is it about my IIS settings? I have not made any remarkable change on them. They are nearly default settings.

My operating system is Windows 8.1 Enterprise N

And i use Visual Studio 2013 (.NET 4.5)

MOD
  • 1,070
  • 3
  • 19
  • 41
  • 1
    I have the same issue right now. It works sometimes, others not. Did you find any resolution or errors that might have caused this? – AdamRoof Jun 15 '15 at 17:42
  • I did the same with the application recycle. My recycle period is set to 3180 minutes. I have very low usage (3 users per week). I am still digging for errors. I'll try to run a trace next time, but it doesn't happen on the right computer at the right time for me to do that – AdamRoof Jun 15 '15 at 17:48

4 Answers4

1

It's not very clear if you are using Owin + Asp.NET Identity but (I assume you are so) check this link, another similar question in SO which explains this issue in much detail and a workaround.

Partial quote:

System.Web has its own master source of cookie information and that isn't the Set-Cookie header. Owin only knows about the Set-Cookie header. A workaround is to make sure that any cookies set by Owin are also

Community
  • 1
  • 1
ram
  • 81
  • 3
  • 4
0

I had the same issue and discovered it happened after running a Crystal Report. The 'Session["Workaround"] = 0;' worked for me, as suggested here: ASP.NET_SessionId + OWIN Cookies do not send to browser

Community
  • 1
  • 1
-1

I have the same issue right now. It works sometimes, others not. Did you find any resolution or errors that might have caused this?

UPDATE: I found a (hopefully) related event log on the server that lead me to run an update on the Owin package (Tools > NuGet Package Manager Console) I ran "Update-Package Microsoft.Owin" and its subsets, and was able to login clean. Then I just updated all the packages in the Packages.config, use caution obviously and test, especially if you don't want to update the jQuery package.

From a couple resources it was leading into being a Response.Flush or .End issue when Owin was trying to check/set the login cookie.

http://katanaproject.codeplex.com/discussions/540202 https://www.nuget.org/packages/Microsoft.Owin/3.0.1

Event ID 1309 ASP.NET 4.0.30319.0 Exception message: Server cannot append header after HTTP headers have been sent.

AdamRoof
  • 264
  • 2
  • 11
-1

I had exactly this issue and spend hours trying to work it out. I found out by chance that navigating to a page that had Session["LastPage"] = Request.UrlReferrer.OriginalString; on it, before going to the login page seemed to fix the issue. (Some pages on my site were available without logging in). So I added this line to the login page and it fixed my issue. I guess this is the same type of work around mentioned by Beaniecopter.

Marvin
  • 853
  • 2
  • 14
  • 38
SEBA.Net
  • 1
  • 1