Error Upload file when this web was up host
I write a application to upload file and up to host :
http://www.buiductoan.somee.com/default.aspx
My code:
if (FileUpload1.PostedFile != null)
{
String filename = FileUpload1.PostedFile.FileName;
FileUpload1.PostedFile.SaveAs("C:\\"+filename);
}
I run success in local host but I run on http://www.buiductoan.somee.com/default.aspx has error :
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
And
Access to the path 'C:\Untitled.png' is denied.
Can you help me,please?
Dorababu MekaPosted Sep 13, 2011, 12:07 PM
toanhoi buiPosted Sep 13, 2011, 12:06 PM
Dorababu MekaPosted Sep 13, 2011, 11:54 AM
Initially you have to create some folder in your application and save your files to that folder like
string strFilename = Server.MapPath("Sample") + "//" + "ur uploaded filename";
FileUpload1.SaveAs(strFilename);
If you say directly to save it in C what if the user didn't have C directory?
toanhoi buiPosted Sep 13, 2011, 11:49 AM
Dorababu MekaPosted Sep 13, 2011, 11:43 AM
toanhoi buiPosted Sep 13, 2011, 11:36 AM
Dorababu MekaPosted Sep 13, 2011, 10:45 AM
<pages enableEventValidation="false" viewStateEncryptionMode ="Never" />