I am registered on asp.net for a while but still cant post any new post on this forum. Could you help me please? Or If you know answer on my problem I would realy appriciate any help. I created email form in asp.net for my new website and getting an error.
Could you transfer me somewhere where I can find some answers? Thank you very much.
Description:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local
server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors>
tag should then have its "mode" attribute set to "Off".
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
Good morning Raj, thank you for your last answer. The error report what i am getting is about MAC view state, is it any code what i need to add or do i need to generate unique machine key? I read a bit about it but its not very clear what to do in this situation.
If you have any solution it would be much appresiated. The best regards.
Jiri
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot
be used in a cluster.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
When you deploy as asp.net web app into a web farm environment, each web servers machine.config or web.config must specify the same key used for encrypting the view state. Remember the view state is encrypted for security reasons and each machine.config
on each web server will have a different key so they must all be the same. Best way is to add a machineKey element into each of the web server's web.config and define the same keys and algorithm.
I am using Visual Web Developer 2010. When I try to download that .doc on localhost all is fine, but when I deploy package and upload it to server VWD2010 absolutely ignore all my .doc or pdf files. Do you have any idea how to fix it?
Thank you for your help. Last time you helped me a lot. I would like to ask for help one more time. I am doing counter on my www.onlinelessonsinenglish.co.uk, counter should be displayed on the top right corner. "OUR WEBSITE HASE BEEN VISITED "?"
TIMES". When I run script on localhost all is fine but when I upload stuff on the server the "? number of hits" is not displayed.
try to add gobal.ascx page with the following code:
public static int Count = 0;
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["myCount"] = Count;
}
void Session_Start(object sender, EventArgs e)
{
Count = Convert.ToInt32(Application["myCount"]);
Application["myCount"] = Count + 1;
// Code that runs when a new session is started
}
Line 30: int hits = Int32.Parse(tmpDs.Tables[0].Rows[0]["hits"].ToString());
Line 31: hits += 1;
Line 32: tmpDs.Tables[0].Rows[0]["hits"] = Application["myCount"].ToString(); Line 33: tmpDs.WriteXml(Server.MapPath("~/counter.xml"));
Line 34: }
jirkovesely
Member
12 Points
10 Posts
error sending email
Feb 21, 2012 06:17 PM|LINK
I am registered on asp.net for a while but still cant post any new post on this forum. Could you help me please? Or If you know answer on my problem I would realy appriciate any help. I created email form in asp.net for my new website and getting an error. Could you transfer me somewhere where I can find some answers? Thank you very much.
Code is:
string name = "Name :" + txtName.Text + '\n';
string surname = "Surname: " + txtSurname.Text + '\n';
string email = "Email: " + txtEmail.Text + '\n';
string textarea = "Message: " + txtArea.Value;
string body = name + surname + email + textarea;
MailMessage message = new MailMessage();
message.From = new MailAddress("some_email@ some_email.co.uk");
message.To.Add(new MailAddress("isome_email@ some_email.co.uk"));
message.To.Add(new MailAddress("some_email@hotmail.co.uk"));
message.Subject = "Contact Form";
message.Body = body;
SmtpClient client = new SmtpClient();
client.Host = "smtp.live.com";
client.EnableSsl = true;
System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
NetworkCred.UserName = "some_email@ some_email.co.uk";
NetworkCred.Password = "some_password";
client.Port = 25;
client.Credentials = NetworkCred;
try
{
client.Send(message);
lblContactMessage.Text = "EMAIL WAS SENT, THANK YOU.";
}
catch
{
lblContactMessage.Text = "AN ERROR OCCURRED, PLEASE TRY AGAIN LATER.";
}
Error is:
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration>Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration>rajsedhain
Contributor
4181 Points
1041 Posts
Re: error sending email
Feb 21, 2012 06:33 PM|LINK
try to add the block of code with customErros mode = off and see the actual error.
you can assign the credentials like this:
SmtpClient sc = new SmtpClient("YourMailRelayServer"); sc.Credentials = new System.Net.NetworkCredential("yourusername", "yourpassword");Raj Sedhain
jirkovesely
Member
12 Points
10 Posts
Re: error sending email
Feb 22, 2012 01:38 AM|LINK
jirkovesely
Member
12 Points
10 Posts
Re: error sending email
Feb 29, 2012 08:04 AM|LINK
Good morning Raj, thank you for your last answer. The error report what i am getting is about MAC view state, is it any code what i need to add or do i need to generate unique machine key? I read a bit about it but its not very clear what to do in this situation. If you have any solution it would be much appresiated. The best regards.
Jiri
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
<%@ Page Language="C#" Debug="true" %>
or:
2) Add the following section to the configuration file of your application:
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack Trace:
[ViewStateException: Invalid viewstate.
Client IP: 81.109.253.209
Port: 51447
Referer: http://www.onlinelessonsinenglish.co.uk/Apply.aspx
Path: /Apply.aspx
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
ViewState: /wEPDwUKLTcxMTE1Njk4NQ9kFgJmD2QWAgIDD2QWAgIDD2QWAgJVDw8WAh4EVGV4dAUaRU1BSUwgV0FTIFNFTlQsIFRIQU5LIFlPVS5kZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQUeY3RsMDAkTWFpbkNvbnRlbnQkYnRuQXBwbHlTZW5k+vPULO/xE9Yh/vGBxMKBCS7IJFKxE5q1Y+6RG8jW/jc=]
[HttpException (0x80004005): Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.]
System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) +235
System.Web.UI.ViewStateException.ThrowMacValidationError(Exception inner, String persistedState) +14
System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) +274
System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) +4
System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) +37
System.Web.UI.HiddenFieldPageStatePersister.Load() +241
System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +106
System.Web.UI.Page.LoadAllState() +43
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253
System.Web.UI.Page.ProcessRequest() +78
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.apply_aspx.ProcessRequest(HttpContext context) +4
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
rajsedhain
Contributor
4181 Points
1041 Posts
Re: error sending email
Feb 29, 2012 02:07 PM|LINK
When you deploy as asp.net web app into a web farm environment, each web servers machine.config or web.config must specify the same key used for encrypting the view state. Remember the view state is encrypted for security reasons and each machine.config on each web server will have a different key so they must all be the same. Best way is to add a machineKey element into each of the web server's web.config and define the same keys and algorithm.
Something like this:
to get the machine key visit this link:
http://www.developmentnow.com/articles/machinekey_generator.aspx
Raj Sedhain
jirkovesely
Member
12 Points
10 Posts
Re: error sending email
Mar 21, 2012 05:11 PM|LINK
Hi Rajsedhain,
Thank you for your answer, you helped me a lot. Now I am trying to download a .doc file from my website, code:
protected void btnMasterEnglish_Click(object sender, EventArgs e)
{
Response.ContentType = "application/ms-word";
Response.AppendHeader("Content-Disposition", "attachment; filename=Brochure_English");
string FilePath = Server.MapPath("~/download/brochure_english.doc");
Response.TransmitFile(FilePath);
Response.End();
}
I am using Visual Web Developer 2010. When I try to download that .doc on localhost all is fine, but when I deploy package and upload it to server VWD2010 absolutely ignore all my .doc or pdf files. Do you have any idea how to fix it?
Thank you for your time.
rajsedhain
Contributor
4181 Points
1041 Posts
Re: error sending email
Mar 21, 2012 08:12 PM|LINK
these links might be helpful:
http://forums.asp.net/t/1774584.aspx/1
http://www.4guysfromrolla.com/webtech/091201-1.shtml
http://www.c-sharpcorner.com/UploadFile/mahesh/FileUpload10092005172118PM/FileUpload.aspx?ArticleID=79850d6d-0e91-4d7b-9e27-a64a09b0ee6b
show your file upload code, if you still have problem to upload file.
Raj Sedhain
jirkovesely
Member
12 Points
10 Posts
Re: error sending email
Apr 02, 2012 11:25 AM|LINK
Hello Rajsedhain
Thank you for your help. Last time you helped me a lot. I would like to ask for help one more time. I am doing counter on my www.onlinelessonsinenglish.co.uk, counter should be displayed on the top right corner. "OUR WEBSITE HASE BEEN VISITED "?" TIMES". When I run script on localhost all is fine but when I upload stuff on the server the "? number of hits" is not displayed.
Code is very simple:
protected void Page_Load(object sender, System.EventArgs e)
{
this.countMe();
DataSet tmpDs = new DataSet();
tmpDs.ReadXml(Server.MapPath("~/counter.xml"));
lblCounter.Text = tmpDs.Tables[0].Rows[0]["hits"].ToString();
}
private void countMe()
{
DataSet tmpDs = new DataSet();
tmpDs.ReadXml(Server.MapPath("~/counter.xml"));
int hits = Int32.Parse(tmpDs.Tables[0].Rows[0]["hits"].ToString());
hits += 1;
tmpDs.Tables[0].Rows[0]["hits"] = hits.ToString();
tmpDs.WriteXml(Server.MapPath("~/counter.xml"));
}
And on the website code is:
<p class="masterbrochure">OUR WEBSITE HASE BEEN VISITED <b><asp:Label ID="lblCounter" runat="server"></asp:Label></b> TIMES</p>
Counter.xml file is in root directory so I have no idea where is the error. Please help. Many thanks
Jiri
rajsedhain
Contributor
4181 Points
1041 Posts
Re: error sending email
Apr 02, 2012 01:26 PM|LINK
try to add gobal.ascx page with the following code:
public static int Count = 0; void Application_Start(object sender, EventArgs e) { // Code that runs on application startup Application["myCount"] = Count; } void Session_Start(object sender, EventArgs e) { Count = Convert.ToInt32(Application["myCount"]); Application["myCount"] = Count + 1; // Code that runs when a new session is started }and inside page_load:
protected void Page_Load(object sender, EventArgs e) { this.countMe(); DataSet tmpDs = new DataSet(); tmpDs.ReadXml(Server.MapPath("~/counter.xml")); Label1.Text = tmpDs.Tables[0].Rows[0]["hits"].ToString(); } private void countMe() { DataSet tmpDs = new DataSet(); tmpDs.ReadXml(Server.MapPath("~/XMLFile.xml")); int hits = Int32.Parse(tmpDs.Tables[0].Rows[0]["hits"].ToString()); hits += 1; tmpDs.Tables[0].Rows[0]["hits"] = Application["myCount"].ToString(); tmpDs.WriteXml(Server.MapPath("~/counter.xml")); }Raj Sedhain
jirkovesely
Member
12 Points
10 Posts
Re: error sending email
Apr 23, 2012 09:38 AM|LINK
Hi Raj,
did you mean Global.ascx or Global.aspx?
Because I am getting error on: