Deployment issue asp.net web application

258 views Asked by At

I have shopping cart web application. when I am running that in my local machine that works fine. But when i hosted my application online i am facing two issue

  1. when i login and uses my application after some time user automatically signout and redirected to login page.
  2. some of the pictures retrieved and shown by the datalist control not shown only the text is show

I am using method FormsAuthentication.RedirectFromLoginPage(username, true) for the login the user

my web.config file is

<?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>

And the login page code i'm using

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


                }
2

There are 2 answers

0
Prakash Kumar Jha On BEST ANSWER

For all that issue i changed timeout lots of time and also added session tag to web.config for not works for me know finally i understand authentication has nothing to do with Session.

All authentcation information is stored in the authentication cookie, When a user needs to loggin again, it means that the authentication ticket is expired.

The solution is very simple, add a machine key to your web.config or use this online tool machine key

5
Chinmoy On

Regarding the sign-out problem, are you using sessions to manage the logged-in state? If yes, try setting the session lifetime to a higher value.

If pictures are not showing, it might be a problem with the path (absolute path). Right click on the image and check the path it is trying to fetch the image from. I hope you did not store the pictures in the database! You only have the links to the pictures. Right?

This is how you can change the authentication timeout in web.config:

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

The time is in milliseconds.