0

MasterPage:

<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>

ASPX page:

<%@ Page Title="" Language="C#" MasterPageFile="~/NewFMaster.master" AutoEventWireup="true" CodeFile="Home17.aspx.cs" Inherits="Home17" %>
....

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
....

<form id="form1" runat="server">
    <div class="form-group">
        <div class="col-sm-6">
            <asp:TextBox ID="txtFullName" runat="server" CssClass="name" placeholder="Full Name"></asp:TextBox>                                 
        </div>
        <div class="col-sm-6">
            <asp:TextBox ID="txtContact" runat="server" MaxLength="12" CssClass="name" placeholder="Contact Number" />
        </div>
    </div>
 <asp:Button ID="submitButton" runat="server"  CssClass="submit-btn" style="width:150px" Text="Submit"  OnClick="submitButton_Click"/>      
</form>

....
</asp:Content>

CodeBehind:

public partial class Home17 : System.Web.UI.MasterPage
{
....

protected void submitButton_Click(object sender, EventArgs e)   
{
    Response.Redirect("Home16.aspx");
}

If I remove OnClick="submitButton_Click" from asp:Button line, then the page atleast displays, otherwise I get "Internal Server error"

Internal Server Error

Web.Config: CustomerErrors are off & have tried with both true/false for debug Web.config

UPDATE 24 Apr 2018: Now Internal Server Error is shown on all pages. Entire site has gone done.

In the error Log last error is: (I have added the new keys)

<Error>
   <Message>Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster,
      ensure that &lt;machineKey&gt; configuration specifies the same validationKey and validation algorithm.
      AutoGenerate cannot be used in a cluster.

     http://go.microsoft.com/fwlink/?LinkID=314055</Message>
    <PageName>http://www.***.*******.com/Product.aspx?productID=69584&amp;productID=69584</PageName>
   <Date>4/23/2018 8:58:44 PM</Date>
   <UTC>4/24/2018 3:58:44 AM</UTC>
 </Error>

Note: The hosting provider is BigRock. (have asked them for help but they simply said I'll have to resolve it, its not their issue)

Shailesh
  • 79
  • 13
  • 1
    You markup is `OnClick="submitButton_Click"` where as your server method is `btnSubmit_Click`. Change it and it should work – Izzy Apr 23 '18 at 11:04
  • @izzy sorry I copied the wrong function... actually, the proper function exists and when I double click the asp button in design view it goes to that event handler function. – Shailesh Apr 23 '18 at 11:09
  • 1
    You did not mention what was the actual errormessage, please provide that. – Esko Apr 23 '18 at 11:13
  • 1
    If you're getting a 500 internal server error then you can [turn off custom errors in your web.config file](http://www.dotnettricks.com/learn/aspnet/turn-off-aspnet-custom-errors-in-webconfig) in order to be able to see the actual exception and stack trace. – bassfader Apr 23 '18 at 11:21
  • Does this code work on your local dev machine? – Izzy Apr 23 '18 at 11:26
  • Try Adding `InValidateRequest="false"` in `<%@ Page` tag and let us know if it resolves issue. If it resolves issue, we can further debug it. – abhijeet chimankar Apr 23 '18 at 11:30
  • You are using a master page file but i could not see any `content place holder`. You should use a `content place holder` like ` ` ..........`Content place holder` id should be the id from master page file. – Nagib Mahfuz Apr 23 '18 at 12:29
  • @NagibMahfuz Content placeholder is already present(had not added it earlier to reduce clutter), Have updated it above. – Shailesh Apr 24 '18 at 05:04
  • @Shailesh Do you get the same error on your local development computer? If so, have you tried setting a breakpoint to take a look at the exception (maybe using a try-catch)? Or is it only happening in the deployed application? In that case, have you tried adding some kind of error logging to log the underlying exception that seems to be thrown? – bassfader Apr 24 '18 at 08:49
  • @bassfader It is difficult to get the site on Local Environment due to size. As of now, entire site is shown "Internal Server Error". I have updated above the last entry from the log. I have revert back the web.config as it was. But, still site is down. – Shailesh Apr 24 '18 at 12:07
  • @Shailesh well that is a problem that makes identifying the error unnecessarily hard, you'll need a local version to be able to properly debug it... At least the added error log ("Validation of viewstate MAC failed") now gives some kind of indication. Have you checked the `machineKey` setting? Maybe have a look at the following related question: https://stackoverflow.com/questions/6259844/asp-net-validation-of-viewstate-mac-failed – bassfader Apr 24 '18 at 12:36
  • @bassfader I had looked into similar threads. But, the error showed up after I created this thread. Also, it is about a different page (product.aspx). I didnt do anything related to updating the keys, since I suspected issue might be because of something I did while editing the web.config file. (i.e, while acting on the suggestions here) – Shailesh Apr 24 '18 at 14:57
  • @bassfader I have added the new keys. But still gets Internal Server error throughout the site. – Shailesh Apr 24 '18 at 15:50
  • @Shailesh I think you really need to get a local version up and running, so you can properly debug your code and find the problem. The internal server error indicates that an exception is thrown somewhere, but without getting more informations (type, message and stacktrace of the exception) it'll be next to impossible to pinpoint the cause of the problem... – bassfader Apr 24 '18 at 16:05

0 Answers0