title: Button placed on the website Site.Master doesn't redirect when clicked from default.aspx, however button works from all other pages
body: <p>I have added a search box on the Site.Master page of a website (ASP.NET) that I am developing using Visual Studio.  </p>
  
  <p><strong>Problem</strong>
  However I noticed that when I access default.aspx page and I click on the Search button it doesn't ReDirect (you may see below the code behind).  However when I access other pages of my website the button does redirect as required.</p>
  
  <p><strong>Update</strong>
  I am noticing that all button on the default.apsx page are not raising postback on default.aspx page.... on the other pages. Buttons are working fine...</p>
  
  <p>Code:</p>
  
  <p><strong>SiteMaster</strong></p>
  
  <pre><code>&lt;body&gt;
      &lt;form runat="server"&gt;
          &lt;asp:ScriptManager runat="server"&gt;
                  .......
          &lt;/asp:ScriptManager&gt;
  
          &lt;div class="navbar navbar-inverse navbar-fixed-top"&gt;
              &lt;div class="container"&gt;
                  &lt;div class="navbar-header"&gt;
                      ......
                  &lt;/div&gt;
                  &lt;div class="navbar-collapse collapse"&gt;
                      ......
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;br /&gt;
  
  
          &lt;div class="container body-content"&gt;
              &lt;asp:SiteMapPath ID="SiteMapPath1" runat="server"&gt;
                  &lt;/asp:SiteMapPath&gt;
  
              &lt;div class="row"&gt;
                      &lt;div class="col-md-8"&gt;
  
                      &lt;/div&gt;
  
                      &lt;div class="col-md-4"&gt;
  
     &lt;div class="input-group"&gt;
       &lt;asp:TextBox class="form-control" type="text" ID="tbSearch" width="100%" runat="server" placeholder="Search for recipes..."&gt;&lt;/asp:TextBox&gt;
  
       &lt;span class="input-group-btn"&gt;
      &lt;asp:Button class="btn btn-primary" type="button" ID="btnSearch" runat="server" Text="Search Recipes" CausesValidation="False" OnClick="btnSearch_Click" ToolTip="Search Recipes" ValidateRequestMode="Disabled" /&gt;
       &lt;/span&gt;
     &lt;/div&gt;
  
                      &lt;/div&gt;
                 &lt;/div&gt;  
  
              &lt;br /&gt;
              &lt;asp:ContentPlaceHolder ID="MainContent" runat="server"&gt;
  
  
             .....     
  
  
  &lt;/asp:ContentPlaceHolder&gt;
  </code></pre>
  
  <p><strong>SiteMaster.cs</strong></p>
  
  <p>In the Code behind I have the following code:</p>
  
  <pre><code>public partial class SiteMaster : MasterPage
      {
          private const string AntiXsrfTokenKey = "__AntiXsrfToken";
          private const string AntiXsrfUserNameKey = "__AntiXsrfUserName";
          private string _antiXsrfTokenValue;
  
          protected void Page_Init(object sender, EventArgs e)
          {
              // The code below helps to protect against XSRF attacks
              var requestCookie = Request.Cookies[AntiXsrfTokenKey];
              Guid requestCookieGuidValue;
              if (requestCookie != null &amp;&amp; Guid.TryParse(requestCookie.Value, out requestCookieGuidValue))
              {
                  // Use the Anti-XSRF token from the cookie
                  _antiXsrfTokenValue = requestCookie.Value;
                  Page.ViewStateUserKey = _antiXsrfTokenValue;
              }
              else
              {
                  // Generate a new Anti-XSRF token and save to the cookie
                  _antiXsrfTokenValue = Guid.NewGuid().ToString("N");
                  Page.ViewStateUserKey = _antiXsrfTokenValue;
  
                  var responseCookie = new HttpCookie(AntiXsrfTokenKey)
                  {
                      HttpOnly = true,
                      Value = _antiXsrfTokenValue
                  };
                  if (FormsAuthentication.RequireSSL &amp;&amp; Request.IsSecureConnection)
                  {
                      responseCookie.Secure = true;
                  }
                  Response.Cookies.Set(responseCookie);
              }
  
              Page.PreLoad += master_Page_PreLoad;
          }
  
          protected void master_Page_PreLoad(object sender, EventArgs e)
          {
  
  
              if (!IsPostBack)
              {
                  // Set Anti-XSRF token
                  ViewState[AntiXsrfTokenKey] = Page.ViewStateUserKey;
                  ViewState[AntiXsrfUserNameKey] = Context.User.Identity.Name ?? String.Empty;
              }
              else
              {
                  // Validate the Anti-XSRF token
                  if ((string)ViewState[AntiXsrfTokenKey] != _antiXsrfTokenValue
                      || (string)ViewState[AntiXsrfUserNameKey] != (Context.User.Identity.Name ?? String.Empty))
                  {
                      throw new InvalidOperationException("Validation of Anti-XSRF token failed.");
                  }
              }
          }
  
          protected void Page_Load(object sender, EventArgs e)
          {
  
  
          }
  
          protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e)
          {
              Context.GetOwinContext().Authentication.SignOut();
          }
  
          protected void btnSearch_Click(object sender, EventArgs e)
          {
              var searchText = Server.UrlEncode(tbSearch.Text); // URL encode in case of special characters
              Response.Redirect("~/Results.aspx?search=" + searchText);
  
          }
      }
  </code></pre>
  
  <p><strong>Default.aspx.cs</strong></p>
  
  <pre><code>public partial class _Default : Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
  
  
              if (!HttpContext.Current.User.Identity.IsAuthenticated)
              {
  
                  Label2.Visible = true;
                  Label1.Visible = false;
                  tbPost.Visible = false;
                  Button1.Visible = false;
              }
  
              if (HttpContext.Current.User.Identity.IsAuthenticated)
              {
                  Label1.Visible = true;
                  Label2.Visible = false;
                  tbPost.Visible = true;
                  Button1.Visible = true;
  
              }
  
  
              if (!this.IsPostBack) 
              {
                  BindRpt();
              }
  
          }
  </code></pre>