?
Solved

Upload file with ftp on server

Posted on 2011-10-09
3
Medium Priority
?
276 Views
Last Modified: 2012-05-12
In my asp.net C# web application i am using telerik upload control to upload the image or file on server with ftp.
My Code is as follows:
ftpfilepath = AppFunctions.GetFTPUrl() + AppFunctions.GetFileUploadPath() + filename;
                        ftpWebRequest = (FtpWebRequest)WebRequest.Create(ftpfilepath);
                        ftpWebRequest.Method = WebRequestMethods.Ftp.UploadFile;
                        ftpWebRequest = AppFunctions.GetNetworkCredentials(ref ftpWebRequest);
                        streamReader = new StreamReader(uploadedFile.InputStream);
                        byte[] fileContents = Encoding.UTF8.GetBytes(streamReader.ReadToEnd());
                        streamReader.Close();
                        ftpWebRequest.ContentLength = fileContents.Length;

                        stream = ftpWebRequest.GetRequestStream();
                        stream.Write(fileContents, 0, fileContents.Length);
                        stream.Close();
                        ftpWebResponse = (FtpWebResponse)ftpWebRequest.GetResponse();
                        ftpWebResponse.Close();

When I run it on my local machine, it works fine, but as soon as i uploaded it on the production server, it gives error as :
Error Occured : Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I also tried
<location allowOverride="false">
  <system.web>      
      <trust level="Full" originUrl=""/>

but then it gives error as :
Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.

Please advice
0
Comment
Question by:ziorinfo
  • 2
3 Comments
 
LVL 9

Expert Comment

by:jkofte
ID: 36941436
you have to give write permission to the user that uses asp.net processes for that folder.
0
 

Author Comment

by:ziorinfo
ID: 36947075
Thanks jkofte,

The problem is we are using Godaddy for website hosting and as per server administrator there is no iis user to give permission to the folder.
0
 
LVL 9

Accepted Solution

by:
jkofte earned 1000 total points
ID: 36954976
maybe you should contact their support and ask them to give write permission to that folder for asp.net worker process.
or you may change it from the control panel.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question