2011-10-23 205 views
1

我有购物车Web应用程序。当我在我的本地机器上运行时,运行良好。但是,当我主持我的应用程序在网上我面临的二期部署问题asp.net web应用程序

  1. 当我登录,一段时间用户自动signout并重定向到登录页面后使用我的应用程序。
  2. 有些不是只显示文本由DataList控件检索和显示的图片是显示

我使用的方法FormsAuthentication.RedirectFromLoginPage(用户名,真实)的登录用户

我的网站config文件是

<?xml version="1.0"?> 

<!-- 
    For more information on how to configure your ASP.NET application, please visit 
    http://go.microsoft.com/fwlink/?LinkId=169433 
    --> 

<configuration> 
    <connectionStrings> 
     <add name="shopingConnectionString1" connectionString="workstation id=shoppingpra.mssql.somee.com;packet size=4096;user id=pramuk98;pwd=kumarjha;data source=shoppingpra.mssql.somee.com;persist security info=False;initial catalog=shoppingpra" 
      providerName="System.Data.SqlClient" /> 


    </connectionStrings> 

    <system.web> 



     <compilation debug="true" targetFramework="4.0" /> 
     <authentication mode="Forms"> 
     <forms defaultUrl="default.aspx" loginUrl="login1.aspx" timeout="1000000" cookieless="AutoDetect" ></forms> 
     </authentication> 
     <authorization> 
     <deny users="?"/> 
     </authorization> 

    </system.web> 

</configuration> 

和登录页面的代码我使用

User Name<br /> 
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
    ControlToValidate="TextBox1" ErrorMessage="fill usename "></asp:RequiredFieldValidator> 
<br /> 

Password<br /> 
    <asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox> 
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
    ControlToValidate="TextBox2" ErrorMessage="fill password"></asp:RequiredFieldValidator> 
<br /> 


<asp:ImageButton ID="ImageButton3" runat="server" AlternateText="sign in" 
    onclick="ImageButton3_Click" ImageUrl="~/img/str/buttons/sign in.bmp" /> 

     protected void ImageButton3_Click(object sender, ImageClickEventArgs e) 
     { 
      int flag = 0; 
      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["shopingConnectionString1"].ConnectionString); 
      string s = "select * from login"; 
      SqlCommand com = new SqlCommand(s, con); 
      con.Open(); 
      if (con.State == ConnectionState.Open) 
      { 
       SqlDataReader dtr; 
       dtr = com.ExecuteReader(); 
       while (dtr.Read()) 
       { 
        if (dtr[0].ToString().Equals(TextBox1.Text) && dtr[1].ToString().Equals(TextBox2.Text)) 
        { 
         flag = 1; 

         Response.Cookies["uname"].Value = TextBox1.Text; 
         Response.Cookies["pwd"].Value = TextBox2.Text; 
         Response.Cookies["role"].Value = dtr[2].ToString(); 
         FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false); 
        } 
        else 
        { 
         Label1.Text = "your credential are incorrect"; 
        } 


       } 
+0

你可以在web.config中的窗体身份验证设置超时值。 – iandayman

+0

超时值不适用于我 –

回答

0

对于所有这一问题,我改变了超时大量的时间,并添加会话标记到web.config为我不工作知道最后我明白身份验证与Session无关。

所有的认证信息都存储在认证cookie中,当用户需要重新登录时,表示认证凭证已过期。

的解决方案是非常简单的,加一台机器关键是你的web.config文件或使用这个在线工具 machine key

1

关于注销问题,您是否使用会话来管理登录状态?如果是,请尝试将会话生存期设置为更高的值。

如果图片没有显示,可能是路径问题(绝对路径)。右键单击图像并检查尝试从中获取图像的路径。我希望你没有把图片存储在数据库中!你只有链接到图片。对?

这是你如何可以在web.config中更改身份验证超时:

<system.web> 
    <authentication mode="Forms"> 
      <forms timeout="1000000"/> 
    </authentication> 
</system.web> 

的时间以毫秒为单位。

+0

不,我只是使用我写FormsAuthentication.RedirectFromLoginPage(用户名,真)的方法。其实我不知道如何管理按会话登录的状态。 –

+0

在这种情况下,设置表单认证超时并检查它是否工作。 – r3st0r3

+0

我做了这个,但它不工作