473,569 Members | 2,716 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload/Download Security Question

Hello, I am following along with an example of how to do uploads and download
from your application.

The download seems to wok just fine, but the upload does not. Each time I
attempt to upload, I get and exception with the error message being "{"Logon
failure: unknown user name or bad password.\r\n" }". I am trying to move the
file to shared directory on another server, and I am guessing that perhaps I
need to do something on my shared server to allow my application to be able
to write files to it. What exactly do I need to do, or is there some other
error? Here is the code I an using to upload files....

string loadDir = @"e:\products\S peed\Attachment s";
System.Web.Http PostedFile postedFile = uploadedFile.Po stedFile;
string filename = Path.GetFileNam e(postedFile.Fi leName);
string contentType = postedFile.Cont entType;
int contentLength = postedFile.Cont entLength;
postedFile.Save As(loadDir + _DirectorySepar atorChar.ToStri ng() + filename);

Are there some considerations that I should make for where I locate the
directory where I uploade files? I think I have heard that is should
segregated from where my application is, does this mean the same server or
should it be isolated to a different server?

Thanks in advance for your assistance!!!
Nov 19 '05 #1
4 1616
By default the ASPNET user account does not have access to network
directories. Either grant it access or have ASP.NET run under a different
user account by using impersonation.

For example, you can add a line similar to this to your web.config file:
<identity impersonate="tr ue" userName="domai n\MyAppUser">
password="passw ord"/>

For testing purposes you can have it use your user account since you know
you have the necessary permissions to write to that network location.

Here's more info on impersonation:
http://msdn.microsoft.com/library/de...ersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Jim Heavey" <Ji*******@disc ussions.microso ft.com> wrote in message
news:6C******** *************** ***********@mic rosoft.com...
Hello, I am following along with an example of how to do uploads and
download
from your application.

The download seems to wok just fine, but the upload does not. Each time I
attempt to upload, I get and exception with the error message being
"{"Logon
failure: unknown user name or bad password.\r\n" }". I am trying to move
the
file to shared directory on another server, and I am guessing that
perhaps I
need to do something on my shared server to allow my application to be
able
to write files to it. What exactly do I need to do, or is there some
other
error? Here is the code I an using to upload files....

string loadDir = @"e:\products\S peed\Attachment s";
System.Web.Http PostedFile postedFile = uploadedFile.Po stedFile;
string filename = Path.GetFileNam e(postedFile.Fi leName);
string contentType = postedFile.Cont entType;
int contentLength = postedFile.Cont entLength;
postedFile.Save As(loadDir + _DirectorySepar atorChar.ToStri ng() +
filename);

Are there some considerations that I should make for where I locate the
directory where I uploade files? I think I have heard that is should
segregated from where my application is, does this mean the same server or
should it be isolated to a different server?

Thanks in advance for your assistance!!!

Nov 19 '05 #2
By default the ASPNET user account does not have access to network
directories. Either grant it access or have ASP.NET run under a different
user account by using impersonation.

For example, you can add a line similar to this to your web.config file:
<identity impersonate="tr ue" userName="domai n\MyAppUser">
password="passw ord"/>

For testing purposes you can have it use your user account since you know
you have the necessary permissions to write to that network location.

Here's more info on impersonation:
http://msdn.microsoft.com/library/de...ersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Jim Heavey" <Ji*******@disc ussions.microso ft.com> wrote in message
news:6C******** *************** ***********@mic rosoft.com...
Hello, I am following along with an example of how to do uploads and
download
from your application.

The download seems to wok just fine, but the upload does not. Each time I
attempt to upload, I get and exception with the error message being
"{"Logon
failure: unknown user name or bad password.\r\n" }". I am trying to move
the
file to shared directory on another server, and I am guessing that
perhaps I
need to do something on my shared server to allow my application to be
able
to write files to it. What exactly do I need to do, or is there some
other
error? Here is the code I an using to upload files....

string loadDir = @"e:\products\S peed\Attachment s";
System.Web.Http PostedFile postedFile = uploadedFile.Po stedFile;
string filename = Path.GetFileNam e(postedFile.Fi leName);
string contentType = postedFile.Cont entType;
int contentLength = postedFile.Cont entLength;
postedFile.Save As(loadDir + _DirectorySepar atorChar.ToStri ng() +
filename);

Are there some considerations that I should make for where I locate the
directory where I uploade files? I think I have heard that is should
segregated from where my application is, does this mean the same server or
should it be isolated to a different server?

Thanks in advance for your assistance!!!

Nov 19 '05 #3
Thanks...But why does it work when I am physically signed on? Is it not
using the ASP.Net account then?

Do I just grant MachineName\asp net the access event though my ID is logged
on to the domain account?
Nov 19 '05 #4
Thanks...But why does it work when I am physically signed on? Is it not
using the ASP.Net account then?

Do I just grant MachineName\asp net the access event though my ID is logged
on to the domain account?
Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5211
by: Todd Acheson | last post by:
I'm having a small problem with uploading files in ASP.NET. My html page for uploading has something similar to: <form id="Form1" method="post" enctype="multipart/form-data" runat="server"> <input id="MyFile" type="file" runat="server" size="50"> <asp:Button Runat="server" ID="btnUpload" Text="UPLOAD" /> </form> .. . .and the...
0
227
by: Jim Heavey | last post by:
Hello, I am following along with an example of how to do uploads and download from your application. The download seems to wok just fine, but the upload does not. Each time I attempt to upload, I get and exception with the error message being "{"Logon failure: unknown user name or bad password.\r\n" }". I am trying to move the file to...
6
3604
by: Paul | last post by:
Hi there, When adding a "File Field" HTML control to an aspx page to facilitate file uploading, the following occurs: 1. You select a file that is larger than the allowed size limit. 2. Once the user selected the too large file, the page is redirected to a "page not found" error page. 3. This is as per the docs, but my question is:
3
3550
by: Demetri | last post by:
Hello, I'm involved in developing an application which has the need to transfer files automtically once a laptop is connected back to the network. The application i'm developing will automatically realize the network is available and thus pass a file to a web service that will know what to do with the file. My question is what is the...
0
9780
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
9
3881
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This works fine. The doctors want fewer steps to follow. So, it was asked if I can configure the browser to load/submit the image 'xray.tif' each time they...
1
1884
by: lPrentice | last post by:
Hello, After all this time, Linux file permissions still confuse me at times. I have a Python web-based application with an file (images) upload module. The application is running on two remote servers and a local server on my development network. The upload module works just fine when I'm uploading to my remote servers. But when I try...
12
2473
by: GuangXiN | last post by:
I want the file upload element disappear, instead of it, I place a text box and a button with my own css defination. but it doesn't work on IE7. What should I do now? <form action="upload.php" method="POST" enctype="multipart/form-data"> <p> <span>Select photo:</span> <input type="file" name="photo" style="display:none;"> <input type="text"...
3
1499
by: mp33487 | last post by:
I'm trying to upload/download files programmaticly to a records management system. I have it working fine on my dev machine using vb.net code-behind pages but when I place it on the server when it goes to upload files it (datatable of file paths and data stored in a session var) it errors because the code can't find the files. It seems to...
2
5167
dlite922
by: dlite922 | last post by:
I have an intranet LAMP server and I use PHP to upload files. It is of course faster to download the same file than to upload it. I understand ISPs throttle their network for download speed, than upload since most people download from the internet vs upload. My question is if it's a local intranet with a couple of users, why is it faster...
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.