Click here to Skip to main content
15,904,500 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
here i am getting error like
c:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\root\4d627a43\ab2fd5d9\App_Web_index.cshtml.32644dcb.zykik1o6.0.cs(36): error CS1001: Identifier expected

controler code
C#
[HttpGet]
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Up(HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file == null)
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
                else if (file.ContentLength > 0)
                {
                    int MaxContentLength = 1024 * 1024 * 3; //3 MB
                    string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf" };

                    if (!AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                    {
                        ModelState.AddModelError("File", "Please file of type: " + string.Join(", ", AllowedFileExtensions));
                    }

                    else if (file.ContentLength > MaxContentLength)
                    {
                        ModelState.AddModelError("File", "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB");
                    }
                    else
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var path = Path.Combine(Server.MapPath("~/Upload"), fileName);
                        file.SaveAs(path);
                        ModelState.Clear();
                        ViewBag.Message = "File uploaded successfully. File path : ~/Upload/" + fileName;
                    }
                }
            }
            return View();
        }

    }
}
Posted
Updated 17-Aug-15 2:33am
v2
Comments
Richard MacCutchan 17-Aug-15 8:35am    
Where is line 36?
Member 11755579 17-Aug-15 8:52am    
i dont find that one pplz let me know...
Richard MacCutchan 17-Aug-15 10:26am    
Well you cannot expect anyone here to guess where line 36 is in your code.

1 solution

Compilation Error CS1001 means you did not supply an identifier for an Enum, parameter name, etc...

Check this link for more info. CS1001 Error
 
Share this answer
 
v2
Comments
Member 11755579 17-Aug-15 9:15am    
still did not get the solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900