2011-10-23 8 views
1

私はショッピングカートWebアプリケーションを持っています。ローカルマシンでうまく動作しているときに実行します。私はオンライン私のアプリケーションをホストされているときに私は、ログインして自動的にサインアウトし、ログインページにリダイレクトされ、いくつかの時間後に、ユーザー自分のアプリケーションを使用する場合でも、私は2つの問題配備の問題asp.net Webアプリケーション

  1. に直面しています。
  2. のDataListコントロールによって取得され、示される画像の一部示されていないテキストだけは、私は、ユーザー

    自分のWebログインのための方法FormsAuthentication.RedirectFromLoginPage(ユーザ名、true)を使用しています

を示しています.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に追加しました。私のためには動作しません。最終的に私は認証がセッションとは関係ないことを理解しています。

すべての認証情報が認証Cookieに格納されます。ユーザーが再度ログインする必要がある場合は、認証チケットが失効したことを意味します。

ソリューションを使用すると、フォーム認証のためのweb.configにタイムアウト値を設定することができます machine key

1

ログアウトの問題について、セッションを使用してログインしている状態を管理していますか? 「はい」の場合は、セッションの有効期間をより高い値に設定してください。

画像が表示されない場合は、パス(絶対パス)に問題がある可能性があります。イメージを右クリックし、イメージを取得しようとしているパスを確認します。私はあなたがデータベースに写真を保存していないことを願っています!あなたは写真へのリンクしかありません。右?

これは、web.configファイルで認証タイムアウトを変更する方法です。

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

時間はミリ秒です。

+0

いいえ私はFormsAuthentication.RedirectFromLoginPage(username、true)を書くメソッドを使用しています。実際にはセッションごとにログイン状態を管理する方法がわかりません。 –

+0

その場合は、フォーム認証のタイムアウトを設定し、動作しているかどうかを確認してください。 – r3st0r3

+0

私はこれをしましたが、動作していませんでしたが、

関連する問題