Access to the path 'D:\PLESKVHOST\vhosts\abhisaartechnologies.com\vns.abhisaartechnologies.com\Upload\resturent.png' is denied.
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.UnauthorizedAccessException: Access to the path 'D:\PLESKVHOST\vhosts\abhisaartechnologies.com\vns.abhisaartechnologies.com\Upload\resturent.png' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true">, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 25: {
Line 26: string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
Line 27: FileUpload1.SaveAs(Server.MapPath("~/Upload/" + filename));
Line 28: SqlConnection con = new SqlConnection(constr);
Line 29: con.Open();
Source File: d:\pleskvhost\vhosts\abhisaartechnologies.com\vns.abhisaartechnologies.com\Cpanel\Category.aspx.cs Line: 27
this is my code:--
protected void btnsubmit_Click(object sender, EventArgs e)
{
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(Server.MapPath("Upload/" + filename));
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand com = new SqlCommand("Insert into tbl_CategoryMaster (Category,catId,CatImage) values(@Category,@catId,@CatImage)", con);
com.Parameters.AddWithValue("@Category", SqlDbType.NVarChar).Value = txtcat.Text;
com.Parameters.AddWithValue("@catId", SqlDbType.NVarChar).Value = txtid.Text;
com.Parameters.AddWithValue("@CatImage", filename);
int obj = Convert.ToInt32(com.ExecuteNonQuery());
if (obj > 0)
{
Label1.Text = "Save";
}
else
{
Label1.Text = "Try Again";
}
con.Close();
txtcat.Text = "";
}
plz help me sir how to solve problem