我有購物車Web應用程序。當我在我的本地機器上運行時,運行良好。但是,當我主持我的應用程序在網上我面臨的二期部署問題asp.net web應用程序
- 當我登錄,一段時間用戶自動signout並重定向到登錄頁面後使用我的應用程序。
- 有些不是隻顯示文本由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";
}
}
你可以在web.config中的窗體身份驗證設置超時值。 – iandayman
超時值不適用於我 –