简体   繁体   中英

Asp.net web site configuration , page not writting log

I have a really strange problem,

Here's my Default.aspx Page Code behind :

protected void Page_Load(object sender, EventArgs e)
{
    WebUtils.WriteLog("On the login page");
    if (IsPostBack)
    {

        if (!String.IsNullOrEmpty(txtUsername.Text) && !String.IsNullOrEmpty(txtPassword.Text))
        {
            WebUtils.WriteLog("On essai de connecter" + txtUsername.Text);
            UIBase temp = new UIBase();

            FIQFacade facade = temp.facade;

            User user = (User)facade.userFact.GetObjectByLoginName(txtUsername.Text);

            if (user != null)
            {
                WebUtils.WriteLog("User Trouvé" + txtUsername.Text);
                if (user.Password == WebUtils.getMd5Hash(txtPassword.Text))
                {
                    User userLogin = (User)facade.userFact.GetObjectByLoginName(txtUsername.Text);
                    if (userLogin != null)
                    {
                        Session[UIBase.CST_LOGGED_USER] = userLogin;
                        WebUtils.WriteLog("On ce log" + txtUsername.Text);
                        Response.Redirect("pages/ReservationSalleInterne.aspx");
                    }
                }
                else if (facade.userFact.UserLoginDataIsValid(txtUsername.Text, txtPassword.Text, "NDS", configs["ldapPath"].ToString(), ""))
                {
                    User userLogin = (User)facade.userFact.GetObjectByLoginName(txtUsername.Text);
                    Session[UIBase.CST_LOGGED_USER] = userLogin;
                    WebUtils.WriteLog("On ce log" + txtUsername.Text);
                    Response.Redirect("pages/ReservationSalleInterne.aspx");
                }
            }

        }

    }
    else
    {
        WebUtils.WriteLog("On est pas en postback on delogue" );
        Session[UIBase.CST_LOGGED_USER] = null;
        Session["langue"] = "1";
    }
}



}

Here is my Defautl.aspx page Code :

<%@ Page Language="C#"  AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
<!doctype html>
<!--[if lt IE 8 ]><html lang="en" class="no-js ie ie7"><![endif]-->
<!--[if IE 8 ]><html lang="en" class="no-js ie"><![endif]-->
<!--[if (gt IE 8)|!(IE)]><!--><html lang="en" class="no-js"><!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<title>Desa Altilogix</title>
<meta name="description" content="">
<meta name="author" content="">

<!-- Global stylesheets -->
<link href="css/reset.css" rel="stylesheet" type="text/css">
<link href="css/common.css" rel="stylesheet" type="text/css">
<link href="css/form.css" rel="stylesheet" type="text/css">
<link href="css/standard.css" rel="stylesheet" type="text/css">
<link href="css/special-pages.css" rel="stylesheet" type="text/css">

<!-- Favicon -->
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<link rel="icon" type="image/png" href="favicon-large.png">

<!-- Modernizr for support detection, all javascript libs are moved right above     </body> for better performance -->
<script src="js/libs/modernizr.custom.min.js"></script>

 </head>

 <!-- the 'special-page' class is only an identifier for scripts -->
 <body class="special-page login-bg dark">



<section id="login-block">
    <div class="block-border"><div class="block-content">

        <!--
        IE7 compatibility: if you want to remove the <h1>, 
        add style="zoom:1" to the above .block-content div
        -->

        <div class="block-header"><img src="images/LogoDesa.png"  style="height:70px;"/></div>

        <!--<p class="message error no-margin">Error message</p>-->

        <form class="form with-margin" name="login-form" id="login"  runat="server">
            <input type="hidden" name="a" id="a" value="send">
            <p class="inline-small-label">
                <label for="login"><span class="admin">Utilisateur</span></label>
                <asp:TextBox  type="text" name="login" id="txtUsername" class="full-width" value="" runat="server" />

            </p>
            <p class="inline-small-label">
                <label for="pass"><span class="admin">Mot de passe</span></label>
                <asp:TextBox   TextMode="Password" name="pass" id="txtPassword" class="full-width" value="" runat="server"/>

            </p>

            <button type="submit"  class="float-right" runat="server" Text="Login">Se connecter</button>

            <p class="input-height">
                <input type="checkbox" name="keep-logged" id="keep-logged" value="1" class="mini-switch" checked="checked">
                <label for="keep-logged" class="inline">Rester connecté</label>
            </p>
        </form>

    </div></div>
</section>

<!--

Updated as v1.5:
Libs are moved here to improve performance

-->

<!-- Generic libs -->
<script src="js/libs/jquery-1.6.3.min.js"></script>
<script src="js/old-browsers.js"></script>      <!-- remove if you do not need older browsers detection -->

<!-- Template libs -->
<script src="js/common.js"></script>
<script src="js/standard.js"></script>
<!--[if lte IE 8]><script src="js/standard.ie.js"></script><![endif]-->
<script src="js/jquery.tip.js"></script>

<!-- example login script -->


</body>
</html>

So my problem is that when i'm trying to login in my website, The page refresh and nothing happen, at first I was thinking that my Uservalidation Was wrong, so I've put some log. But I've find out that the log never Get written when i'm trying to login and the login don't work.

I don't think the error is in my code I think it's maybe an IIS configuration. I don't seems to have the error when im local browsin with the Visual studio express server.

But when i'm on a real server the problem is happening once in a while. When I have the problem I have two solution: 1- doing an IISRESET or 2 - waiting and after 3-5 minute the problem disapear, until it came back randomly...

Please help me. Thanks.

If you want more information just ask, i'll be waiting to answer or receive an explanation.

Thanks !

EDIT :

I've posted this a few days ago : .net dropDownList losing value after postback in IE

I've just added log in this page too and it's the same problem. When my dropdownlist stop working the log don't get written. Really strange problem, I hope someone will be able to help me.

EDIT 2 :

Here's my web.config

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
Note: As an alternative to hand editing this file you can use the 
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in 
machine.config.comments usually located in 
\Windows\Microsoft.Net\Framework\v2.x\Config 
-->
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
  <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">




    </sectionGroup>
  </sectionGroup>
 </sectionGroup>
  </configSections>
  <appSettings>
    <add key="conn_string" value="data source=HY-SQL;initial catalog=reservation;user id=UserAboveReservation;password=UserAboveReservation" />
    <add key="defaultUserID" value="1" />
  </appSettings>
  <connectionStrings />
  <system.web>


        <sessionState mode="InProc"  />
  </system.web>

</configuration>

Edit 3 :

Even if you don't know the solution maybe gave me a hint or an idea ... Because i'm pulling my air off for the moment. At first I tough it was a session problem, but when I saw that the log did not write in the file I've lost all hope ;) maybe it's a cookie issue, something client side ... help please :)

I found The problem !!!

The output Caching was enable in IIS for all .aspx pages.

Deleting this corrected all my problems.

Thanks all !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM