asp.net web应用程序的部署问题

asp.net web应用程序的部署问题,asp.net,asp.net-development-serv,Asp.net,Asp.net Development Serv,我有购物车web应用程序。当我在我的本地机器上运行时,工作正常。但当我在线托管我的应用程序时,我面临两个问题 当我登录并在一段时间后使用我的应用程序时,用户会自动注销并重定向到登录页面 datalist控件检索和显示的一些图片不显示,只显示文本 我正在使用FormsAuthentication.RedirectFromLoginPage(用户名,true)方法登录用户 我的web.config文件是 <?xml version="1.0"?> <!-- For more

我有购物车web应用程序。当我在我的本地机器上运行时,工作正常。但当我在线托管我的应用程序时,我面临两个问题

  • 当我登录并在一段时间后使用我的应用程序时,用户会自动注销并重定向到登录页面
  • datalist控件检索和显示的一些图片不显示,只显示文本
  • 我正在使用FormsAuthentication.RedirectFromLoginPage(用户名,true)方法登录用户

    我的web.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";
                        }
    
    
                    }
    
    用户名

    密码

    受保护的无效ImageButton3\u单击(对象发送者,ImageClickEventArgs e) { int标志=0; SqlConnection con=新的SqlConnection(ConfigurationManager.ConnectionString[“ShopingConnectionString”].ConnectionString); string s=“选择*登录”; SqlCommand com=新的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); } 其他的 { Label1.Text=“您的凭证不正确”; } }
    关于注销问题,是否使用会话管理登录状态?如果是,请尝试将会话生存期设置为更高的值

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

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

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

    时间以毫秒为单位。

    对于所有这些问题,我更改了很多超时时间,并在web.config中添加了会话标记,用于“不适用于我知道最终我了解身份验证与会话无关”

    所有身份验证信息都存储在身份验证cookie中,当用户需要再次登录时,这意味着身份验证票证已过期

    解决方案非常简单,可以将机器密钥添加到web.config或使用此在线工具

    您可以在web.config中为表单身份验证设置超时值。超时值不适用于meNo我只是使用写入FormsAuthentication.RedirectFromLoginPage(用户名,true)的方法。实际上,我不知道如何按会话管理登录状态。在这种情况下,请设置窗体身份验证超时并检查它是否有效。我这样做了,但它不起作用。我这样做了,但它不起作用。我猜您在代码中的某个地方重写了它。如果正在代码中手动重写它。