Click here to Skip to main content
15,848,319 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a web application when we click first time on any page it redirect to the log in page,
when i log in again i can access the page and it works fine it is only giving error when i'm hosting it on IIS

i'm using
iis 8 4.0
os: sql server 2012
browser: IE 10

im using form authentication the user can see the login page before login and once he logs in and tries to go the next page he is redirected to the login page again again he enter the credentials the page works fine but when i restart the server the error cones again

web key
<identity impersonate="true" />
<authentication mode="Forms">
<sessionState timeout="180" />
Updated 4-Oct-13 21:14pm
ZurdoDev 4-Oct-13 11:23am    
Perhaps you have an error? Or even better, a question?

1 solution

use Generic Handler[Global.asax] file

C# code

<%@ Application Language="C#" %>

<script runat="server">

    void Application_Start(object sender, EventArgs e)
        // Code that runs on application startup


    void Application_End(object sender, EventArgs e)
        //  Code that runs on application shutdown


    void Application_Error(object sender, EventArgs e)
        // Code that runs when an unhandled error occurs


    void Session_Start(object sender, EventArgs e)
        // Code that runs when a new session is started
        Session["Authenticate"] = "";

    void Session_End(object sender, EventArgs e)

    void Application_OnPostRequestHandlerExecute()

    void CheckLogin()
        string Url = Request.RawUrl;
        int count = Url.Length - 10;
        string TestUrl = Url.Substring(count);
        string SessionData = Session["Authenticate"].ToString();
        if (SessionData == "" && TestUrl != "Login.aspx")

put the code in login page.cs

Session["Authenticate"] = "Yes";
Share this answer
write2varun 4-Oct-13 21:56pm    
Thank you
I will try this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900