繁体   English   中英

Asp.net网站配置,页面未写入日志

[英]Asp.net web site configuration , page not writting log

我有一个很奇怪的问题,

这是我的Default.aspx页面代码:

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";
    }
}



}

这是我的Defautl.aspx页面代码:

<%@ 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>

所以我的问题是,当我尝试登录自己的网站时,页面刷新而没有任何反应,起初我以为Uservalidation是错误的,所以我放置了一些日志。 但是我发现,当我尝试登录并且登录不起作用时,日志永远不会被写入。

我认为错误不在我的代码中,我认为这可能是IIS配置。 我在Visual Studio Express服务器上使用本地浏览器时似乎没有错误。

但是,当我在真实服务器上时,该问题有时会发生。 当我遇到问题时,我有两种解决方法:1-执行IISRESET或2-等待并在3-5分钟后问题消失,直到它随机返回...

请帮我。 谢谢。

如果您想了解更多信息,请询问,我将等待回答或得到说明。

谢谢 !

编辑:

我几天前发布了此内容: .net dropDownList在IE中回发后丢失了值

我也刚刚在此页面中添加了日志,这是同样的问题。 当我的下拉列表停止工作时,不会写入日志。 真是个奇怪的问题,希望有人能够帮助我。

编辑2:

这是我的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>

编辑3:

即使您不知道解决方案,也可能给了我一个提示或想法...因为我暂时不在现场。 起初,我很难理解这是一个会话问题,但是当我看到日志没有写到文件中时,我就失去了所有希望;)也许这是一个cookie问题,有些客户端...请帮助:)

我发现了问题!

在IIS中为所有.aspx页启用了输出缓存。

删除此内容将纠正我的所有问题。

谢谢大家!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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