Showing posts with label default. Show all posts
Showing posts with label default. Show all posts

Wednesday, March 28, 2012

System.IO.Path.GetTempFileName

Hi,
System.IO.Path.GetTempFileName( ) is supposed to create a temporary file and give us the path to the created file.
By default, where does this temp file get created? C:\Temp, C:\WinNT ?
Bcos right now this fails and error we get is "Access denied". But we dont know which folder's permissions to change as we dont know where this temp file is supposed to get created.

It will be in the ASPNET user's Temp Directory. For example, on mine:
C:\Documents and Settings\ComputerName\ASPNET\Local Settings\Temp


You are right ! I just found that out by using

tempPathString = Path.GetTempPath()
Thanks !


correctomundo!!
I know this is an old post, but System.IO.Path.GetTempPath() only puts stuff in the ASPNET user directory when the app runs on XP Pro. That is fine for development, but when the app is deployed to a Windows 2003 server the method returns C:\Windows\Temp. Calling GetTempFileName() creates a temp file there. Surely, it isn't safe or a best practice to write to the Windows directory, is it?

Monday, March 26, 2012

System.net.Mail default smtp host

i was using the old system.web.mail classes.
and try to sent emails with net.mail, but i get an exception:
System.Net.Mail.SmtpFailedRecipientException was unhandled by user code
Message="Mailbox unavailable. The server response was: 5.7.1 Unable to relay for bla@dotnet.itags.org.bla.bla"

host property of SmtpClient must be set up! but what is default smpt host? is it "localhost"? i get an exception if i use it.Tongue Tied
thank u for ur advice

if i use this code it works for me (System.Web.Mail):

SmtpMail.SmtpServer =null;

SmtpMail.Send(mail);
because the name of the local SMTP server is used!!!!!!
WHAT NAME IS IT? how can i find it out?
i need the name to set the Host property of SmtpClient (System.Net.Mail).
thank u for ur advice


Hello.

I believe that you should use the classes SmtpClient and MailMessage to send your email message.


i still need ur help
Hello.
See if this helps:
http://www.developer.com/net/net/article.php/3511731

hi,

i m sorry but it has nothing to do with my question!


Hello.
not sure on what you0re after, but normally you use set that propertywith the name of the server. and you're the only one that know that...

Hi,
Did you find a solution to this problem...I am having the same problem. I use System.Mail.Net with the following code
SmtpClient client = new SmtpClient("localhost");
client.Send(message);
And get the following error
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc@.
abc.abc
Many thanks for any help you can provide.

msplants wrote:

Hi,
Did you find a solution to this problem...I am having the same problem. I use System.Mail.Net with the following code
SmtpClient client = new SmtpClient("localhost");
client.Send(message);
And get the following error
Mailbox unavailable. The server response was: 5.7.1 Unable to relay for abc@.
abc.abc
Many thanks for any help you can provide.


As the error says:
The email server is not accepting mail from the server that the code resides in...
despite the fact that this site is based on 1.1's mail code, the server errors apply to any code trying to use a mail server
http://www.systemwebmail.net/faq/4.3.11.aspx

hey,

no, i still can not find the answer!

localhost is not a default smtp server.
HOW TO FIND THE NAME OFdefault smtp server?


stWooE wrote:

HOW TO FIND THE NAME OFdefault smtp server?


- Ask your IT department
or
- Goto the computer where the SMTP service lives, and use either (1) The name of the computer or (2) the IP address of the computer
And as noted in my last post, if there is any sort of permissions/security set on the SMTP service, you'll need to allow your web server to "relay" mail through it, all of it is at that website i linked to
- i talk all the time about my local smpt server
- for sure, i have tried the name of my comuter and ip, i get the same error!
i can only send emails with the deprecated classes from the version 1.1
but thank u anyway

this problem disppears if I change the Relay properties to "All except the list below", however this is not an acceptable configuration. Any help from here?
Thanks in advance


Hi, i know this post is rather old but i've searched the forums and found this thread hanging around and i have exactly the same problem as the original poster and i was wondering if perhaps some1 could give me some insight as to how to solve this this time around.

What do i type in host?

tx in advance,

Me


It's an even older post now, and I spent ages finding an answer to this problem, which still doesn't clearly appear her. So here goes:

If you are using the SMTP server that is installed with IIS, you need to allow relaying for 127.0.0.1 (localhost) in the SMTP Server properties. This can be found on the Access tab at the bottom - Relay Restrictions.

Under "Select which computer may relay through this virtual server", "Only the list below" should be checked. If not, check it, as this will prevent spammers hijacking your SMTP server. Then click "Add" and add 127.0.0.1 into the IP address.

In your script, you may well have something like this:

SmtpClient client = new SmtpClient();
client.Send(message);

You now need to add the bold line below:

SmtpClient client = new SmtpClient();
client.Host = "127.0.0.1";
client.Send(message);

Hope This Helps.

Saturday, March 24, 2012

System.Net.Sockets.SocketException+webservice+Sourabh Das

Hi,
I have placed a webservice in the webserver. When I access it from a webpage, default.aspx on a click of a button i get the following error:

No connection could be made because the target machine actively refused it
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

Source Error:

Line 91: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/getProducts", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 92: public System.Data.DataSet getProducts(int productid) {
Line 93: object[] results = this.Invoke("getProducts", new object[] {
Line 94: productid});
Line 95: return ((System.Data.DataSet)(results[0]));


Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\6dcecb27\a382a372\App_WebReferences.lgdo8f58.0.cs Line: 93

Stack Trace:

[SocketException (0x274d): No connection could be made because the target machine actively refused it]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +1002082
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431

[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.GetRequestStream() +1504461
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +103
localhost.ProductsService.getProducts(Int32 productid) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\6dcecb27\a382a372\App_WebReferences.lgdo8f58.0.cs:93
_Default.btnCategory_Click(Object sender, EventArgs e) in D:\users\Padmajamvl\arete\www\Default.aspx.vb:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

Please tell me what is the error. Its urgent.
Regards."Unable to connect to the remote server"
This means, you must update the web reference to access the web service (Rebuild the WSDL file automatically)
Or the server doesn't allow access to the web service folder (not marked as a web application on IIS)