What's wrong in my asp.net class?
<p>I have a problem witth google bot only. Browser users - ok.
When Google bot visit my site, bot receive redirect 302</p>

<pre><code>HTTP/1.1 302 Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
Location: /
Server: Microsoft-IIS/7.5
Set-Cookie: .ASPXANONYMOUS=lKQmNw8kzQEkAAAANmMwZjdkMjctZWJlMy00YzIwLTg0NDgtMjhiYzc0MTRjNWU1d8RvBwzlWgqhhMrkp2BdSRBo7mA1; expires=Fri, 27-Apr-2012 00:46:43 GMT; path=/; HttpOnly
Set-Cookie: ASP.NET_SessionId=tznuqgtchg5hzgks5aowirfg; path=/; HttpOnly
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 17 Feb 2012 14:06:43 GMT
Content-Length: 118

&lt;html&gt;&lt;head&gt;&lt;title&gt;Object moved&lt;/title&gt;&lt;/head&gt;&lt;body&gt;
&lt;h2&gt;Object moved to &lt;a href="/"&gt;here&lt;/a&gt;.&lt;/h2&gt;
&lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>I use form authentication on site. So my aspx page is public content+login form to enter account. 
But pages whithout login form,  only with public content - indexes ok (status 200).</p>

<p>What the problem with my public pages with login form in it?</p>

<p>Here part of web.config</p>

<pre><code>&lt;anonymousIdentification enabled="true" /&gt;
        &lt;authentication mode="Forms"&gt;
            &lt;forms 
            cookieless="UseDeviceProfile" 
            loginUrl="~/AccessDenied.aspx" 
            name="GSFORMAUTH" 
            protection="All" 
            slidingExpiration="true" 
            timeout="44000"&gt;&lt;/forms&gt;
        &lt;/authentication&gt;
</code></pre>

<p>I tried cookieless="UseCookies" instead of cookieless="UseDeviceProfile" - but it's also error 302</p>

<p>I saw website through user-agent switcher in Mozilla - it works good. It's not server setting, because only part of site pages reply 302 redirect for bots</p>

<p>My Loginbox.ascx.cs</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class Controls_LoginBox : System.Web.UI.UserControl
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Page.User.Identity.IsAuthenticated)
        {
            DateTime dt = new DateTime();
            dt = (this.Profile.New.VisitDate == DateTime.MinValue) ? DateTime.Now.AddDays(-1) : this.Profile.New.VisitDate;
            using (SqlConnection cn = new SqlConnection(ASO.Mercanter.Globals.Settings.Articles.ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("aso_CompanyProfile_GetState", cn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@User", SqlDbType.NVarChar).Value = this.Page.User.Identity.Name;                
                cmd.Parameters.Add("@VisitDate", SqlDbType.DateTime).Value = dt;
                cn.Open();
                SqlDataReader read = cmd.ExecuteReader();
                if (read.Read())
                {
                    Label lb1 = (Label)LoginView1.FindControl("lbLabMyMessages");
                    if (lb1!=null) lb1.Visible = (bool)read["MyMessages"];
                    Label lb2 = (Label)LoginView1.FindControl("lbOrder");
                    if (lb2!=null) lb2.Visible = (bool)read["MyOrders"];
                    Label lb3 = (Label)LoginView1.FindControl("lbPartnerNews");
                    if (lb3!=null) lb3.Visible = (bool)read["MyPartnerNews"];
                    Label lb4 = (Label)LoginView1.FindControl("labProfileRating");
                    if (lb4!=null) lb4.Text = read["MyPosition"].ToString();
                }
            }
            if (this.Page.User.IsInRole("Персона"))
            {
                HyperLink hl1 = (HyperLink)LoginView1.FindControl("hlPreferenses");
                hl1.NavigateUrl = "~/Person/EditProfile.aspx";
                HyperLink hl2 = (HyperLink)LoginView1.FindControl("hlOrder");
                hl2.Visible = false;
                HyperLink hl3 = (HyperLink)LoginView1.FindControl("hlPartnerNews");
                hl3.Visible = false;
                HyperLink hl4 = (HyperLink)LoginView1.FindControl("hlPartners");
                hl4.Visible = false;


                /*HyperLink hl5 = (HyperLink)LoginView1.FindControl("hlStatistics");
                hl5.Visible = false;*/
                //Localize locProfileRating = (Localize)LoginView1.FindControl("locProfileRating");
                //locProfileRating.Visible = true;
                //Label labProfileRating = (Label)LoginView1.FindControl("labProfileRating");
                //labProfileRating.Visible = true;
               /* LinkButton lbIncProfile = (LinkButton)LoginView1.FindControl("lbIncProfile");
                lbIncProfile.Visible = true;*/
                HyperLink hl9 = (HyperLink)LoginView1.FindControl("hlMyMessages");
                hl9.Visible = true;
                hl9.NavigateUrl = "~/Person/MyMessages.aspx";
            }
            else 
            if (this.Page.User.IsInRole("Администратор"))
            {
                HyperLink hl1 = (HyperLink)LoginView1.FindControl("hlPreferenses");
                hl1.Visible = false;
                HyperLink hl2 = (HyperLink)LoginView1.FindControl("hlOrder");
                hl2.Visible = false;
                HyperLink hl3 = (HyperLink)LoginView1.FindControl("hlPartnerNews");
                hl3.Visible = false;
                HyperLink hl4 = (HyperLink)LoginView1.FindControl("hlPartners");
                hl4.Visible = false;
                HyperLink hl6 = (HyperLink)LoginView1.FindControl("hlCategories");
                hl6.Visible = true;
                /*HyperLink hl5 = (HyperLink)LoginView1.FindControl("hlStatistics");
                hl5.Visible = false;*/
                HyperLink hl7 = (HyperLink)LoginView1.FindControl("hlSender");
                hl7.Visible = true;
                HyperLink hl8 = (HyperLink)LoginView1.FindControl("hlAdmins");
                hl8.Visible = true;
                HyperLink hl9 = (HyperLink)LoginView1.FindControl("hlMyMessages");
                hl9.Visible = true;
                hl9.NavigateUrl = "~/Admin/MyMessages.aspx";
                HyperLink hl10 = (HyperLink)LoginView1.FindControl("hlOccupations");
                hl10.Visible = true;
            }
            ((Localize)LoginView1.FindControl("locMessages")).Text = (String)GetLocalResourceObject("MyMessages");
            ((Localize)LoginView1.FindControl("locResponses")).Text = (String)GetLocalResourceObject("Order");
            ((Localize)LoginView1.FindControl("locPartnerNews")).Text = (String)GetLocalResourceObject("PartnerNews");
        }
    }


}
</code></pre>

<p>My Loginbox.ascx</p>

<pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="LoginBox.ascx.cs" Inherits="Controls_LoginBox" %&gt;
&lt;asp:LoginView ID="LoginView1" runat="server" &gt;
    &lt;AnonymousTemplate&gt;
        &lt;asp:Login ID="Login1" runat="server" Width="100%" 
            FailureAction="RedirectToLoginPage" RememberMeSet="True" 
            meta:resourcekey="Login1Resource1"&gt;
            &lt;LayoutTemplate&gt; 
            &lt;asp:Panel CssClass="block" runat="server" DefaultButton="btnLogin" 
                    meta:resourcekey="PanelResource1"&gt; 
            &lt;ul class="auth"&gt;
                &lt;li&gt;
                    &lt;div&gt;
                        &lt;asp:Localize ID="locLoginEmail" runat="server" Text="E-mail" meta:resourcekey="locLoginEmailResource1" 
                            &gt;&lt;/asp:Localize&gt;&lt;/div&gt;
                    &lt;asp:TextBox ID="UserName" runat="server" class="input" 
                        meta:resourcekey="UserNameResource1" /&gt;
                    &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                runat="server" SetFocusOnError="True" Text="*"
                ControltoValidate="UserName" ValidationGroup="Login" 
                        meta:resourcekey="RequiredFieldValidator1Resource1" /&gt;
                &lt;/li&gt;
                &lt;li&gt;
                    &lt;div&gt;&lt;asp:Localize ID="locLoginPass" runat="server" Text="Пароль" 
                            meta:resourcekey="locLoginPassResource1" &gt;&lt;/asp:Localize&gt;&lt;/div&gt;
                    &lt;asp:TextBox ID="Password" runat="server" TextMode="Password" class="input" 
                        meta:resourcekey="PasswordResource1" /&gt;
                    &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator2"
                runat="server" SetFocusOnError="True" Text="*"
                ControltoValidate="Password" ValidationGroup="Login" 
                        meta:resourcekey="RequiredFieldValidator2Resource1" /&gt;
                &lt;/li&gt;
                &lt;li&gt;
                &lt;asp:LinkButton ID="btnLogin" runat="server" CommandName="Login"  
                            ValidationGroup="Login" Text="Войти" CssClass="submit" 
                        meta:resourcekey="btnLoginResource1" /&gt;
                &lt;/li&gt;
                &lt;li&gt;&lt;asp:HyperLink ID="HyperLink6" runat="server" 
                        NavigateUrl="~/PasswordRecovery.aspx" Text="Забыли пароль?" meta:resourcekey="HyperLink6Resource1" 
                        &gt;&lt;/asp:HyperLink&gt;&lt;/li&gt;
            &lt;/ul&gt;


            &lt;/asp:Panel&gt;
            &lt;/LayoutTemplate&gt;
        &lt;/asp:Login&gt;
    &lt;/AnonymousTemplate&gt;


    &lt;LoggedInTemplate&gt;
    &lt;table class="menu2"&gt;
        &lt;tr&gt;
            &lt;td id="liMyMessages"&gt;
            &lt;asp:HyperLink ID="hlMyMessages" runat="server" 
                    NavigateUrl="~/Company/MyMessages.aspx"
                    &gt;&lt;asp:Localize ID="locMessages" 
                    runat="server" Text="Мои сообщения "&gt;&lt;/asp:Localize&gt;
&lt;asp:Label id="lbLabMyMessages" runat="server" Text="new!" Visible="False"&gt;&lt;/asp:Label&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td id="li2"&gt;
            &lt;asp:HyperLink ID="hlSender" runat="server" NavigateUrl="~/Admin/SendNewsletter.aspx" 
                    Visible="False" meta:resourcekey="hlSenderResource1"&gt;&lt;asp:Localize 
                    ID="locSender" runat="server" Text="Рассылка" 
                    meta:resourcekey="locSenderResource1"&gt;&lt;/asp:Localize&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td id="li3"&gt;
            &lt;asp:HyperLink ID="hlAdmins" runat="server" NavigateUrl="~/Admin/ManageUsers.aspx" 
                    Visible="False" meta:resourcekey="hlAdminsResource1" &gt;&lt;asp:Localize 
                    ID="locAdmins" runat="server" Text="Пользователи" 
                    meta:resourcekey="locAdminsResource1"&gt;&lt;/asp:Localize&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td id="li4"&gt;
            &lt;asp:HyperLink ID="hlCategories" runat="server" 
                    NavigateUrl="~/Admin/Categories.aspx" Visible="False" meta:resourcekey="hlCategoriesResource1" 
                    &gt;&lt;asp:Localize ID="locCategories" 
                    runat="server" Text="Категории" meta:resourcekey="locCategoriesResource1"&gt;&lt;/asp:Localize&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td id="li5"&gt;
            &lt;asp:HyperLink ID="hlOccupations" runat="server" 
                    NavigateUrl="~/Admin/Occupations.aspx" Visible="False" meta:resourcekey="hlOccupationsResource1" 
                    &gt;&lt;asp:Localize ID="Localize1" 
                    runat="server" Text="Профили" meta:resourcekey="Localize1Resource1" &gt;&lt;/asp:Localize&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td id="liOrder"&gt;
            &lt;asp:HyperLink ID="hlOrder" runat="server" NavigateUrl="~/Company/MyResponses.aspx"&gt;
            &lt;asp:Localize ID="locResponses" runat="server" Text="Заказы "&gt;&lt;/asp:Localize&gt;
&lt;asp:Label id="lbOrder" runat="server" Text="new!" Visible="False"&gt;&lt;/asp:Label&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td id="liPartnerNews"&gt;
            &lt;asp:HyperLink ID="hlPartnerNews" runat="server" 
                    NavigateUrl="~/Company/MyPartnerNews.aspx"&gt;&lt;asp:Localize ID="locPartnerNews" 
                    runat="server" Text="Новости партнеров "&gt;&lt;/asp:Localize&gt;
&lt;asp:Label id="lbPartnerNews" runat="server" Text="new!" Visible="False"&gt;&lt;/asp:Label&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td id="liPartners"&gt;
            &lt;asp:HyperLink ID="hlPartners" runat="server" 
                    NavigateUrl="~/Company/MyPartners.aspx" 
                    meta:resourcekey="hlPartnersResource1"&gt;&lt;asp:Localize 
                    ID="locPartners" runat="server" Text="Мои партнеры" 
                    meta:resourcekey="locPartnersResource1"&gt;&lt;/asp:Localize&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td id="liProfileRating"&gt;
            &lt;div style="font-weight:bold"&gt;
                &lt;asp:Localize ID="locProfileRating" runat="server" Visible="False" 
                    Text="Ваша анкета в каталоге занимает место: №" 
                    meta:resourcekey="locProfileRatingResource1"&gt;&lt;/asp:Localize&gt;
                &lt;asp:Label ID="labProfileRating" runat="server" Visible="False" 
                    meta:resourcekey="labProfileRatingResource1" &gt;&lt;/asp:Label&gt;
            &lt;/div&gt;
            &lt;/td&gt;
            &lt;td id="liPreferences"&gt;
            &lt;asp:HyperLink ID="hlPreferenses" runat="server" 
                    NavigateUrl="~/Company/EditProfile.aspx" 
                    meta:resourcekey="hlPreferensesResource1"&gt;&lt;asp:Localize ID="MyPreferences" 
                    runat="server" Text="Мои настройки" 
                    meta:resourcekey="MyPreferencesResource1"&gt;&lt;/asp:Localize&gt;
&lt;/asp:HyperLink&gt;
            &lt;/td&gt;
            &lt;td&gt;
                &lt;asp:LoginStatus ID="LoginStatus1" runat="server" CssClass="exit" LogoutText="Выход" 
                    LogoutPageUrl="~/Default.aspx" LogoutAction="Redirect" meta:resourcekey="LoginStatus1Resource1" /&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;

    &lt;/LoggedInTemplate&gt;
&lt;/asp:LoginView&gt;
</code></pre>
