본문 바로가기

Web_Application/ASP.NET MVC

[ASP.NET MVC] Make sure that the controller has a parameterless public constructor



유발소스 ASP.NET MVC /Controller/FileController.cs
        public string storageRoot { get; set; }

        public FileController()
        {
            storageRoot = Server.MapPath("~/App_Data/Upload");
        }

        public FileController(ServerPathProvider pathProvider)
        {
            storageRoot = pathProvider.MapPath();
        }

        public string DoSomething(string path1, string path2, string filename)
        {
             return StorageRoot + "\\" + path1 + "\\" + path2 + "\\" + filename; 
        }
수정
        public string StorageRoot { get; set; }

        public FileController(){}

        public FileController(ServerPathProvider pathProvider)
        {
            storageRoot = pathProvider.MapPath();
        }

        public string DoSomething(string path1, string path2, string filename)
        {        
             storageRoot = Server.MapPath("~/App_Data/Upload");
             return StorageRoot + "\\" + path1 + "\\" + path2 + "\\" + filename; 
        }