Showing posts with label remote. Show all posts
Showing posts with label remote. Show all posts

Wednesday, March 28, 2012

System.IO.FileNotFoundException, When Accessing file in remote ser

I am trying to access files in a remote server from my ASP.NET application,
it is giving System.IO.FileNotFoundException error. I tried mapping that
server location like "H:\ErrorLogs\error.log" still it gives error. I tried
even giving the server name and directory like
"\\server_name\\Directory\\file.log" still it gives file not found exception.
Does anyone help me fix this.

Thanksuse \\machineIP\sharename\filename

"Raja" <Raja@.discussions.microsoft.com> wrote in message
news:DC182C99-4D78-4A68-BEDC-632DDE49A827@.microsoft.com...
> I am trying to access files in a remote server from my ASP.NET
application,
> it is giving System.IO.FileNotFoundException error. I tried mapping that
> server location like "H:\ErrorLogs\error.log" still it gives error. I
tried
> even giving the server name and directory like
> "\\server_name\\Directory\\file.log" still it gives file not found
exception.
> Does anyone help me fix this.
> Thanks
asp.net normally does not have permission to any network resources. to
access a networked drive, you will have to make the asp_net account a domain
account, or specify the userName and password of a domain account in the web
config <impersonate> tag.

-- bruce (sqlwork.com)

"Raja" <Raja@.discussions.microsoft.com> wrote in message
news:DC182C99-4D78-4A68-BEDC-632DDE49A827@.microsoft.com...
> I am trying to access files in a remote server from my ASP.NET
application,
> it is giving System.IO.FileNotFoundException error. I tried mapping that
> server location like "H:\ErrorLogs\error.log" still it gives error. I
tried
> even giving the server name and directory like
> "\\server_name\\Directory\\file.log" still it gives file not found
exception.
> Does anyone help me fix this.
> Thanks

System.IO.FileNotFoundException, When Accessing file in remote ser

I am trying to access files in a remote server from my ASP.NET application,
it is giving System.IO.FileNotFoundException error. I tried mapping that
server location like "H:\ErrorLogs\error.log" still it gives error. I tried
even giving the server name and directory like
"\\server_name\\Directory\\file.log" still it gives file not found exception
.
Does anyone help me fix this.
Thanksuse \\machineIP\sharename\filename
"Raja" <Raja@.discussions.microsoft.com> wrote in message
news:DC182C99-4D78-4A68-BEDC-632DDE49A827@.microsoft.com...
> I am trying to access files in a remote server from my ASP.NET
application,
> it is giving System.IO.FileNotFoundException error. I tried mapping that
> server location like "H:\ErrorLogs\error.log" still it gives error. I
tried
> even giving the server name and directory like
> "\\server_name\\Directory\\file.log" still it gives file not found
exception.
> Does anyone help me fix this.
> Thanks
asp.net normally does not have permission to any network resources. to
access a networked drive, you will have to make the asp_net account a domain
account, or specify the userName and password of a domain account in the web
config <impersonate> tag.
-- bruce (sqlwork.com)
"Raja" <Raja@.discussions.microsoft.com> wrote in message
news:DC182C99-4D78-4A68-BEDC-632DDE49A827@.microsoft.com...
> I am trying to access files in a remote server from my ASP.NET
application,
> it is giving System.IO.FileNotFoundException error. I tried mapping that
> server location like "H:\ErrorLogs\error.log" still it gives error. I
tried
> even giving the server name and directory like
> "\\server_name\\Directory\\file.log" still it gives file not found
exception.
> Does anyone help me fix this.
> Thanks

Monday, March 26, 2012

System.Net.Mail SMTP Pickup Dir

Hi,

I am trying to write .eml files to a remote UNC directory - do you
know if this could be done, such as:

<mailSettings>
<smtp>
<network

host="localhost"
port="25"
/
<specifiedPickupDirectory pickupDirectoryLocation="\\server1\Pickup"/>
</smtp>
</mailSettings
If so, would I have to change the defaultCredentials or the security
context for ASP.NET (using machine.config)? I haven't exactly done
that before.

Thank you,
MichaelFYI: I found the answer in case anyone wonders about this. Make sure
the AppPool for the IIS web site is running as IWAM_machinename and
that the \Pickup windows share allows IWAM_machinename (using same
username/password on remote machine) write access in addition to the
NTFS write for that subdirectory is allowed.

mpaine@.htxml.com wrote:

Quote:

Originally Posted by

Hi,
>
>
I am trying to write .eml files to a remote UNC directory - do you
know if this could be done, such as:
>
<mailSettings>
<smtp>
<network
>
host="localhost"
port="25"
/>
>
<specifiedPickupDirectory pickupDirectoryLocation="\\server1\Pickup"/>
</smtp>
</mailSettings>
>
If so, would I have to change the defaultCredentials or the security
context for ASP.NET (using machine.config)? I haven't exactly done
that before.
>
>
Thank you,
Michael

Saturday, March 24, 2012

System.Net.WebClient and UploadFile() Problem

I am using WebClient to upload a file to a remote server. The call I'm
making looks as follows:
webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Fed
eration.Zip",
@dotnet.itags.org."C:\Temp\Federation.Zip");
'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me exactly
what cannot be found. If I attempt to download this exact file from the same
exact URL using webClient.DownloadFile, it works fine!
Thanks for the help - Amos.You can not simply upload file on a server.
Something should wait for that file at the server end.
So url http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.
but to upload you must write an ASPX page that will accept file and save to
the folder on a server.
George.
"Amos Soma" <amos_j_soma@.yahoo.com> wrote in message
news:OqGt9oK7GHA.1248@.TK2MSFTNGP03.phx.gbl...
>I am using WebClient to upload a file to a remote server. The call I'm
>making looks as follows:
> webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/F
ederation.Zip",
> @."C:\Temp\Federation.Zip");
> 'Federation' is a virtual directory on the server I'm attempting to upload
> the file to. The URL is valid and the file I'm attempting to transfer
> exists. I keep getting 404 errors (not found). It's not clear to me
> exactly what cannot be found. If I attempt to download this exact file
> from the same exact URL using webClient.DownloadFile, it works fine!
> Thanks for the help - Amos.
>
Thus wrote George Ter-Saakov,

> You can not simply upload file on a server.
> Something should wait for that file at the server end.
> So url
> http://sdtpcal.someserver.com/Feder.../Federation.Zip to
> download file looks correct.
> but to upload you must write an ASPX page that will accept file and
> save to the folder on a server.
You only need a web application endpoint for POST requests. If the OP can
use PUT, the web server may support this without any special user code (IIS
does for sure).
Both WebClient.UploadFile(uri, "PUT", fileName) and WebClient.OpenWrite(uri,
"PUT") will do the trick.
Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

System.Net.WebClient and UploadFile() Problem

I am using WebClient to upload a file to a remote server. The call I'm
making looks as follows:

webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Federation.Zip",
@dotnet.itags.org."C:\Temp\Federation.Zip");

'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me exactly
what cannot be found. If I attempt to download this exact file from the same
exact URL using webClient.DownloadFile, it works fine!

Thanks for the help - Amos.You can not simply upload file on a server.
Something should wait for that file at the server end.

So url http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.

but to upload you must write an ASPX page that will accept file and save to
the folder on a server.

George.

"Amos Soma" <amos_j_soma@.yahoo.comwrote in message
news:OqGt9oK7GHA.1248@.TK2MSFTNGP03.phx.gbl...

Quote:

Originally Posted by

>I am using WebClient to upload a file to a remote server. The call I'm
>making looks as follows:
>
webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Federation.Zip",
@."C:\Temp\Federation.Zip");
>
'Federation' is a virtual directory on the server I'm attempting to upload
the file to. The URL is valid and the file I'm attempting to transfer
exists. I keep getting 404 errors (not found). It's not clear to me
exactly what cannot be found. If I attempt to download this exact file
from the same exact URL using webClient.DownloadFile, it works fine!
>
Thanks for the help - Amos.
>
>


Thus wrote George Ter-Saakov,

Quote:

Originally Posted by

You can not simply upload file on a server.
Something should wait for that file at the server end.
So url
http://sdtpcal.someserver.com/Feder.../Federation.Zip to
download file looks correct.
>
but to upload you must write an ASPX page that will accept file and
save to the folder on a server.


You only need a web application endpoint for POST requests. If the OP can
use PUT, the web server may support this without any special user code (IIS
does for sure).

Both WebClient.UploadFile(uri, "PUT", fileName) and WebClient.OpenWrite(uri,
"PUT") will do the trick.

Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

Hi
I am trying to consume a web service from asp.net web page through
HTTP POST method and I am getting the following error message

"System.Net.WebException: The remote server returned an error: (500)
Internal Server Error."

I have been searchign the web and followed all the options which worked

for others

1. Changed the web.config of the web service to accomodate HttpPost
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices
2. Used the HttpRequest.Credentials =
CredentialCache.DefaultCredentials;

I am not sure what is wrong there it fails while the request is sent to

the web service. The web service works fine with other web clients

Let me know your ideas

thanks
MohanOther web clients? What is different? Run the debugger on the server,
set a breakpoint and POST from your client, and step through the code
sirfunusa wrote:
> Other web clients? What is different? Run the debugger on the server,
> set a breakpoint and POST from your client, and step through the code

Other clients I mean when I reference the web service and access the
web method it works fine...But when I use an ASP.NET page with the
HTTPReuest Object as shown below it throws the error

"System.Net.WebException: The remote server returned an error: (500)
Internal Server Error."

Code :

HttpWebRequest wr =
(HttpWebRequest)WebRequest.Create("http://localhost//SubtractNumbers//Service1.asmx//Subtract");

wr.Method = "POST";
wr.ContentType = "application/x-www-form-urlencoded";
//wr.ContentLength = bytes.Length;

StreamWriter writer = new
StreamWriter(wr.GetRequestStream(),System.Text.Enc oding.UTF8);
//// Write the xml text into the stream
writer.WriteLine("Hi");
writer.Close();

WebResponse wrs = wr.GetResponse();
Stream strm = wrs.GetResponseStream();
StreamReader sr = new StreamReader(strm);
String line;
while( (line = sr.ReadLine()) != null)
Response.Write(line);
strm.Close();
sirfunusa wrote:
> Other web clients? What is different? Run the debugger on the server,
> set a breakpoint and POST from your client, and step through the code

Other clients I mean when I reference the web service and access the
web method it works fine...But when I use an ASP.NET page with the
HTTPReuest Object as shown below it throws the error

"System.Net.WebException: The remote server returned an error: (500)
Internal Server Error."

Code :

HttpWebRequest wr =
(HttpWebRequest)WebRequest.Create("http://localhost//SubtractNumbers//Service1.asmx//Subtract");

wr.Method = "POST";
wr.ContentType = "application/x-www-form-urlencoded";
//wr.ContentLength = bytes.Length;

StreamWriter writer = new
StreamWriter(wr.GetRequestStream(),System.Text.Enc oding.UTF8);
//// Write the xml text into the stream
writer.WriteLine("Hi");
writer.Close();

WebResponse wrs = wr.GetResponse();
Stream strm = wrs.GetResponseStream();
StreamReader sr = new StreamReader(strm);
String line;
while( (line = sr.ReadLine()) != null)
Response.Write(line);
strm.Close();
Are you sending the proper XML message (SOAP)? If your message isn't
formatted properly, you will definately get a server 500 error back.
It looks liek you are actually just sending text ("Hi"). That's not a
proper SOAP message. Here is a sample of a SOAP message:
http://www.w3.org/2004/06/03-google-soap-wsdl.html .

I personally much of web services manually because it's just easier to
interop with COM that way.

Here's part of what I do... (also be sure to set your SOAPAction in the
http header!) messageData hold my XML message I'm sending.

ASCIIEncoding encoding = new ASCIIEncoding( );
byte[] buffer = encoding.GetBytes(messageData);

HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create(this.EndPoint);
myRequest.Method = "POST";
myRequest.ContentType = "text/xml";
myRequest.ContentLength = buffer.Length;
myRequest.Headers.Add(String.Format("SOAPAction: \"{0}\"",
operationName));
myRequest.Timeout = 10000;

using (Stream newStream = myRequest.GetRequestStream( )) {
newStream.Write(buffer, 0, buffer.Length);
newStream.Close( );
}

HttpWebResponse myHttpWebResponse =
(HttpWebResponse)myRequest.GetResponse( );

string rawResponse =
GetWebResponseString(myHttpWebResponse);

myHttpWebResponse.Close( );

Here is the GetWebResponseString method...

private static string GetWebResponseString(WebResponse
myHttpWebResponse) {
StringBuilder rawResponse = new StringBuilder( );
using (Stream streamResponse =
myHttpWebResponse.GetResponseStream( )) {
using (StreamReader streamRead = new
StreamReader(streamResponse)) {
Char[] readBuffer = new Char[256];
int count = streamRead.Read(readBuffer, 0, 256);

while (count > 0) {
String resultData = new String(readBuffer, 0,
count);
rawResponse.Append(resultData);
count = streamRead.Read(readBuffer, 0, 256);
}
}
}
return rawResponse.ToString( );
}

Look closely at what is returned. You may actually be getting the
reason for the fault in the message.

Also, if all is successful, you will get an XML message back. Are you
prepared to parse it?

You may want to actually use the .NET web service mechanism if you
don't want to do everything manually. Since you aren't using the .NET
web service mechanism the web.config configuration doesn't apply.

If you are intending to use .NET for web services, then all you have to
do is add the WSDL file as a web reference and use it as though it were
local. There's not really much work to it. If that is the case then
everything I said above is void, since this is the manual way to do it.