Saturday, March 31, 2012
System.Drawing.Printing for web form?
I knew that if i want to make some printout in window form, i can use
"System.Drawing.Printing" namespace.
Is it possible to use this namespace in web form in asp.net?
Thank you
Regards,
Angushi
you print form in the server or in the client?
daniel #
"angus" <angus@.angus.com> wrote in message
news:ukXOkZQTEHA.3512@.TK2MSFTNGP12.phx.gbl...
> Dear All,
> I knew that if i want to make some printout in window form, i can use
> "System.Drawing.Printing" namespace.
> Is it possible to use this namespace in web form in asp.net?
> Thank you
> Regards,
> Angus
>
System.Drawing.Printing for web form?
I knew that if i want to make some printout in window form, i can use
"System.Drawing.Printing" namespace.
Is it possible to use this namespace in web form in asp.net?
Thank you
Regards,
Angushi
you print form in the server or in the client?
daniel #
"angus" <angus@.angus.com> wrote in message
news:ukXOkZQTEHA.3512@.TK2MSFTNGP12.phx.gbl...
> Dear All,
> I knew that if i want to make some printout in window form, i can use
> "System.Drawing.Printing" namespace.
> Is it possible to use this namespace in web form in asp.net?
> Thank you
> Regards,
> Angus
system.enterpriseservices.dll error
I am running a web app on w2k3/IIS 6.0/ASP.net 2.0. This app runs fine on a different server. The error message I get is
Compiler Error Message:CS0006: Metadata file 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll' could not be found
I have seen solutions to remove the "<identity impersonate="true" />" setting from the web.config file. That has not been helpful. Another solution was to delete the system.enterpriseservices.dll from C:\Windows\assembly. I have deleted the file, copied a new .dll, and that did not work. I have reinstalled IIS and ASP.Net 2.0 as well. So far, no dice. Any other ideas are greatly welcomed!
AJ
Hello AJ,
This may be a dumb question, but is the assembly in the GAC on the deployment server? If it isn't, you should be able to add it by running "gacutil /if System.EnterpriseServices.dll" using the 2.0 version of gacutil.exe.
HTH,
Clay
Clay,
Thanks for the response. I just got the problem figured out today.
The file permissions were screwed up. Users did not have read and execute permissions to this folder:
C:\WINDOWS\WinSxS\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790
After I fixed that I got a similar error message as before but it mentioned a system.enterpriseServices.Wrapper.dll and found out that this file was missing
C:\WINDOWS\WinSxS\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790\System.EnterpriseServices.Wrapper.dll
Now it is running like a champ!
AJ
System.IndexOutOfRangeException
The line that throws up the error is the following:
<code>
Line 150: txtCoDeath1a.Text = dtr("COD1a")
</code>
'Dtr' is simply a datareader that has been initialised previously. Iknow I should be checking for nulls in the db, but that isn't theproblem in this instant as the record I'm grabbing does have data forthe field 'COD1a'. It's of type nvarchar, length 150.
I've googled this error and have not found anything that seems directly relevant.
I'm using VB.
Any help much appreciated.
try putting this before your code
if dtr.Read then
dtr("COD1a")
end if
Sorry Chris, I should've posted more of my code.
I already have those lines in the code.
Any other ideas?
Try this
if not System.DBNull(dtr("COD1a")) then
txtCoDeath1a.Text = dtr("COD1a")
end if
Could you post more of your code? Are results coming back from the database? Is there a field called COD1a?
Thanks for the help guys, but I've located the source of theproblem. Very simple; I'd misnamed 'Cod1a'. Its actually 'CodIa'. Spotthe difference? Neither did I for a while!
<Sheepish> Sorry and thanks again.
Wednesday, March 28, 2012
system.IO.File.Exists doesnt working for file that is outside my virtual directory
i have file browser control to select any file and a button to upload
file on my web page now when i select any file. now on click of upload
button i have check that file exist or no
if system.IO.File.Exist(file path) then
...
end if
now when ever i choose file system.IO.File.Exist(file path) return
false, but if i select file from my virtual directory then only it
return true.
so how to select file from any folder on my PC and chech that it exist
or notIt may have to do with the ASP.net user in IIS not having read
permissions on the directories?
Max wrote:
Quote:
Originally Posted by
hi
>
i have file browser control to select any file and a button to upload
file on my web page now when i select any file. now on click of upload
button i have check that file exist or no
>
if system.IO.File.Exist(file path) then
...
end if
now when ever i choose file system.IO.File.Exist(file path) return
false, but if i select file from my virtual directory then only it
return true.
>
so how to select file from any folder on my PC and chech that it exist
or not
Are you using an absolute path or a relative path to the file?
"Max" wrote:
Quote:
Originally Posted by
hi
>
i have file browser control to select any file and a button to upload
file on my web page now when i select any file. now on click of upload
button i have check that file exist or no
>
if system.IO.File.Exist(file path) then
...
end if
now when ever i choose file system.IO.File.Exist(file path) return
false, but if i select file from my virtual directory then only it
return true.
>
so how to select file from any folder on my PC and chech that it exist
or not
>
>
followin is the error i am getting
Server Error in '/' Application.
------------------------
Access to the path
"L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg" is
denied.
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.UnauthorizedAccessException: Access to the
path "L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg"
is denied.
ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS
5 or Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user
(typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET write access to a file, right-click the file in
Explorer, choose "Properties" and select the Security tab. Click "Add"
to add the appropriate user or group. Highlight the ASP.NET account,
and check the boxes for the desired access.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[UnauthorizedAccessException: Access to the path
"L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.File.Delete(String path) +165
CMSAPPS.mas_WMKD_entry.Save_ADD() in
D:\dnSource\HOMEAPPS_mahesh\mas_WMKD_entry.aspx.vb :248
CMSAPPS.mas_WMKD_entry.bttn_Save_Click(Object sender, EventArgs e)
in D:\dnSource\HOMEAPPS_mahesh\mas_WMKD_entry.aspx.vb :221
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
What do you not understand about the exception's explanation?
--
HTH,
Kevin Spencer
Microsoft MVP
Chicken Salad Surgery
Orange you bland I stopped splaying bananas?
"Max" <mahesh.anjani@.gmail.comwrote in message
news:1155306880.304856.71550@.i3g2000cwc.googlegrou ps.com...
Quote:
Originally Posted by
followin is the error i am getting
>
Server Error in '/' Application.
------------------------
>
Access to the path
"L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg" is
denied.
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.UnauthorizedAccessException: Access to the
path "L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg"
is denied.
>
ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS
5 or Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user
(typically IUSR_MACHINENAME) or the authenticated request user.
>
To grant ASP.NET write access to a file, right-click the file in
Explorer, choose "Properties" and select the Security tab. Click "Add"
to add the appropriate user or group. Highlight the ASP.NET account,
and check the boxes for the desired access.
>
Source Error:
>
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
>
>
Stack Trace:
>
>
[UnauthorizedAccessException: Access to the path
"L:\Webhosting\home.gujarat.gov.in\homeapps\imagefi les\images.jpg" is
denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.File.Delete(String path) +165
CMSAPPS.mas_WMKD_entry.Save_ADD() in
D:\dnSource\HOMEAPPS_mahesh\mas_WMKD_entry.aspx.vb :248
CMSAPPS.mas_WMKD_entry.bttn_Save_Click(Object sender, EventArgs e)
in D:\dnSource\HOMEAPPS_mahesh\mas_WMKD_entry.aspx.vb :221
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
>
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
>
System.Management
2005 Express Edition
I put
<%@dotnet.itags.org. Import Namespace="System.Management" %>
in my code. asp page
If I put
Dim objMOS As System.Management.ManagementObjectSearcher
In my vb code, it says that the type is not defined.
Why is this and is there a workaround?"news.orange.nl" <iemand@.microsoft.com> wrote in message
news:468d5931$0$63069$dbd4b001@.news.wanadoo.nl...
> System.Management does not seem to import when I use Visual Web Developer
> 2005 Express Edition
It won't by default...
> In my vb code, it says that the type is not defined.
It will do initially...
> Why is this
Because the System.Management namespace is not part of the default project
template.
> and is there a workaround?
Just add a reference to the System.Management namespace in Project Explorer.
Mark Rae
ASP.NET MVP
http://www.markrae.net
System.Management
2005 Express Edition
I put
<%@dotnet.itags.org. Import Namespace="System.Management" %>
in my code. asp page
If I put
Dim objMOS As System.Management.ManagementObjectSearcher
In my vb code, it says that the type is not defined.
Why is this and is there a workaround?"news.orange.nl" <iemand@.microsoft.comwrote in message
news:468d5931$0$63069$dbd4b001@.news.wanadoo.nl...
Quote:
Originally Posted by
System.Management does not seem to import when I use Visual Web Developer
2005 Express Edition
It won't by default...
Quote:
Originally Posted by
In my vb code, it says that the type is not defined.
It will do initially...
Quote:
Originally Posted by
Why is this
Because the System.Management namespace is not part of the default project
template.
Quote:
Originally Posted by
and is there a workaround?
Just add a reference to the System.Management namespace in Project Explorer.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Monday, March 26, 2012
System.Net is not available in VS2005 Web project
I'm trying to access the System.Net.Mail namespace in an ASP.NET application (not website) and it's not available. Any ideas why not?
It is available in a different web site project, but not in an application.
Thanks,
Kahanu
make sure that a reference to System.dll assembly is exists in your application.
system.net.mail - Help
i used system.web.mail in my previous codes.. now i cannot sendemail... when i used VWD it says that the code im using is obsolete,and that i have to use system.net.mail
here's the code i found in one of the threads
-- Begin Code --
Dim msg As New System.Net.Mail.MailMessage
Dim smtp As New System.Net.Mail.SmtpClient
With msg
.From = New System.Net.Mail.MailAddress("From Mail Address")
.To.Add(New System.Net.Mail.MailAddress("To Mail Address")
.Subject = "Important Message"
.IsBodyHtml = False
.Body = "This email is marked as urgent."
.Headers.Add("Importance", "High")
End With
Try
smtp.Host = "Host Server"
smtp.Send(msg)
Catch ex As Exception
'Handle error
End Try
-- End Code -- (thanks to mr. Jeremy Lucas)
but when i tried the code.. i encountered an error..
Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message:BC30002: Type 'System.Net.Mail.MailMessage' is not defined.
Source Error:
Line 105: Dim msg As New System.Net.Mail.MailMessage
Line 106: Dim smtp As New System.Net.Mail.SmtpClient
Line 107:
im trying to figure this out by importing namespaces like
<% Import namespace ="system.net.mail.smtpclient"%>
<% Import namespace ="system.net.mail.mailmessage"%>
still,, i get the same error.. please help... im totally lost.
I had asked about (and then figured out) some working code on this post
http://forums.asp.net/1007397/ShowPost.aspx
hope that helps
tnx for the reply ... i found out the error.. i have to change ASP.netversion to 2.xxxxxx now im having a new dilemma.. i dunno if i have topost this on a new thread.. but my problem now is thatwhen i tried the code.. it seems ok.. but when i check my mail.. its BLANK...
i checked the mailroot... seems like my mails are either in BADMAIL orin QUEUE... im sure i filled up all the necessary info.. im not surewhy its in BADMAIL..
i cant figure this out because.. months ago. when i usedsystem.web.mail. i can send mail within our connection (notes client)but cannot send outside of the company.
Please help.. im using WINXP.
system.net.mail - email sending no longer working
Hi,
Previously on my web app I had a contact page that would send an email to me with all the filled in values from the user. The email would be sent with the FROM address the user put in, so when I received it I could reply back to them. I had this working for years, and now all of a sudden it errors out.
I get the following error. Please note I was using System.Net.Mail, but changed to a component to try and debug.
I'm wondering what would cause this error to happen suddenly? Perhaps a configuration change in IIS ? What would be a good work around to this ? Is it possible to maybe email from my own domain, but specify a different ReplyTo address?
Thanks,
mike123
Additional Help:452 4.2.2 Mailbox full
] Verify you can send email on behalf of'userFilledInName@dotnet.itags.org.hotmail.com' through the mail server 'domainName.com to'admin@dotnet.itags.org.domainName.com'. 'domainName.com' may not allow relaying for that specific address or domain, resulting with a 500 or larger error.Your server may also require a username and password for authentication, check with your mail server administrator. For additional information, enable logging by setting EmailMessage.Logging = true and if you have file write permission set a path for EmailMessage.LogPath, then check the log. If you are sending from an ASP.NET application and do not have file write access, wrap the EmailMessage.Send() in a Try..Catch() block and call Response.Write( EmailMessage.GetLog() ) from inside or after the Catch(). To ignore this error; set IgnoreRecipientErrors = true
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: aspNetEmail.SmtpProtocolException: [Additional Help:452 4.2.2 Mailbox full
] Verify you can send email on behalf of'userFilledInName@dotnet.itags.org.hotmail.com' through the mail server 'domainName.com to'admin@dotnet.itags.org.domainName.com'. 'domainName.com' may not allow relaying for that specific address or domain, resulting with a 500 or larger error.Your server may also require a username and password for authentication, check with your mail server administrator. For additional information, enable logging by setting EmailMessage.Logging = true and if you have file write permission set a path for EmailMessage.LogPath, then check the log. If you are sending from an ASP.NET application and do not have file write access, wrap the EmailMessage.Send() in a Try..Catch() block and call Response.Write( EmailMessage.GetLog() ) from inside or after the Catch(). To ignore this error; set IgnoreRecipientErrors = true
Source Error:
Line 200:
Line 201:
Line 202: msg.Send()
Line 203: msg = Nothing
Line 204:
Destination Full means exactly that. You're sending to an address where the mailbox will accept no more messages. You can't fix this, the problem is the recipient needs to read their mail and empty their mailbox.
Jeff
Hi Jeff,
Thanks for the lightning quick reply, but sorry I forgot to include this part. I have emptied the mail box, it is definately not full. Also to make sure it wasnt a server side mail problem I also tried sending to other email addresses that also were verified to not be full.
I was thinking it might have something to do with the relaying ? I can paste mail logs if that might help ?
Thanks again,
Mike123
anybody have any other thoughts on this ?
much appreciated
mike123
System.Net.Mail & sending emails with line breaks
Hi,
When a client sends an email via a web form (text entered in a asp:TextBox server control), the email received has no line breaks, and it is displayed in one line. This has bad impact on email readability... How can one overcome this probelm?
Thank you,
Alon
If you are sending mail text in simple text format then you have to use System.Environment.NewLine to move rest text in next line.
SmtpMail.SmtpServer = "1.0.0.127";
MailMessage mm = new MailMessage();
mm.From = "bill@.microsoft.com";
mm.To = "job@.apple.com";
mm.Subject = "";
mm.Body = "line 1" + System.Environment.NewLine + "line 2";
Hi,
Thank you for your reply.
I forgot to metion that the mail is sent in HTML format:
mailMessage.IsBodyHtml =true;
Am I supposed to parse the user's message (the text in the TextBox control), chck for CRLF (or is it \n) and replace it with System.Environment.NewLine? Isn't there some standard way to send the email, as i is in the text box (multiline text box. It looks like a text area)?
Thank you,
Alon
Here is the modified code for HTML formated body
mm.Body = "line 1" + "<br>" + "line 2";
Rest of the code will remain same.
But how can I know where line1 ends and line2 starts? All I have is a string I get form TextBox.Text. From this string I cannot deduce where did the user hit return - it's a "flat" string.
A word about he context of this: this web form is a "Contact Us" page. The TextBox is a multiline text box, which serves as a free text input field.
Thank you,
Alon
As what Firoz said, you have to use the "<br />"
You will use the following code to replace each line in your textbox to break
Replace(textbox1.text, vbCrLf,"<br />")
HTH
Regards
Oooops, now I understand. It works. I thank the both of you.
Alon
System.net.Mail default smtp host
i was using the old system.web.mail classes. |
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.
system.net.mail network host cache?
I need to change the name of the mail server for my .NET application. I changed it in web.config and on the .aspx page that sends the message. However, I still get an error message saying that the remote name could not be resolved, and the error message has the name of theold mail server. I have tried rebooting the server, but still get the same error.
Does .NET save configuration settings somewhere other than web.config? Is something getting cached? Other ideas?
Are you running VS debugger or testing on IIS server?
You can delete all files in cache.
Do you use only one config file?
If you have BLL and DAL, sometimes you have also config files here.
Visit this?site.
http://www.systemwebmail.com/
As Johan said, delete your temporary files, and build your web site again
Thanks
Thanks for the responses.
JohanNL, this site is on an IIS server. There is only one web.config file for the site. I did not implement BLL/DAL.
JohanNL and e_screw - this is probably a dumb question - when you say to delete cache/temp files, do you mean the ones in c:\windows\temp? Or what is the correct location?
You need to clear the ASP.NET temporary files
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
Thanks
System.Net.Mail vs System.Web.Mail
I'm getting an error "Hot not specified" when I try to do my last two lines:
System.Net.Mail.SmtpClient SMTP = new SmtpClient();
SMTP.Send(Message); //Error happens here
But the thing is, in my old use of System.Web.Mail, I never had this
problem. Why do I HAVE to specify the host in the new version and I didn't
have to in the old?
AlexHi,
In oldversion when using System.web.Mail, the SmtpMail class automatically
uses the built-in mail service in Windows 2000. But in new version,
SmtpClient class does not use any default mail service. Hence when using
System.Net.Mail namespace, you need to specify the host.
SmtpClient mailObj = new SmtpClient();
mailObj.Host = "name of the host";
(or)
SmtpClient mailObj = new SmtpClient( "name of the host");
MailMessage mail = new MailMessage("x@.yahoo.co.in", "x@.hotmail.com",
"Testing", "Hello Everybody");
mailObj.Send(mail);
Regards,
Sharmila
"Alex Maghen" <AlexMaghen@.newsgroup.nospam> wrote in message
news:93B69854-ECB5-4DB7-A461-56DD11855C9F@.microsoft.com...
>I want to use the new System.Net.Mail instead of the old System.Web.Mail.
> I'm getting an error "Hot not specified" when I try to do my last two
> lines:
> System.Net.Mail.SmtpClient SMTP = new SmtpClient();
> SMTP.Send(Message); //Error happens here
>
> But the thing is, in my old use of System.Web.Mail, I never had this
> problem. Why do I HAVE to specify the host in the new version and I didn't
> have to in the old?
> Alex
Thank you Sharmila for your input.
Hi Alex,
Thank you for your post.
Unlike System.Web.Mail, which was introduced in the 1.0 Framework,
System.Net.Mail is not built upon the CDO/CDOSYS libraries. Instead it is
written from the ground up without any interop. Thus, it is not dependant
upon on other COM libraries. Although some functionality has been removed,
the new System.Net.Mail namespace is much more versatile than the older CDO
dependant System.Web.Mail.
Other than Sharmila's input about specifying the server in code, you can
also config the Host, Credentials and Port properties for SmtpClient by
using the settings in the application or machine configuration files. For
example:
<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network
host="localhost"
port="25"
defaultCredentials="true"
/>
</smtp>
</mailSettings>
</system.net>
</configuration>
Hope this helps. Please feel free to post here if anything is unclear.
Regards,
Walter Wang
Microsoft Online Community Support
========================================
==========
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
==========
This posting is provided "AS IS" with no warranties, and confers no rights.
System.Net.Mail vs System.Web.Mail
I'm getting an error "Hot not specified" when I try to do my last two lines:
System.Net.Mail.SmtpClient SMTP = new SmtpClient();
SMTP.Send(Message); //Error happens here
But the thing is, in my old use of System.Web.Mail, I never had this
problem. Why do I HAVE to specify the host in the new version and I didn't
have to in the old?
AlexHi,
In oldversion when using System.web.Mail, the SmtpMail class automatically
uses the built-in mail service in Windows 2000. But in new version,
SmtpClient class does not use any default mail service. Hence when using
System.Net.Mail namespace, you need to specify the host.
SmtpClient mailObj = new SmtpClient();
mailObj.Host = "name of the host";
(or)
SmtpClient mailObj = new SmtpClient( "name of the host");
MailMessage mail = new MailMessage("x@.yahoo.co.in", "x@.hotmail.com",
"Testing", "Hello Everybody");
mailObj.Send(mail);
Regards,
Sharmila
"Alex Maghen" <AlexMaghen@.newsgroup.nospam> wrote in message
news:93B69854-ECB5-4DB7-A461-56DD11855C9F@.microsoft.com...
>I want to use the new System.Net.Mail instead of the old System.Web.Mail.
> I'm getting an error "Hot not specified" when I try to do my last two
> lines:
> System.Net.Mail.SmtpClient SMTP = new SmtpClient();
> SMTP.Send(Message); //Error happens here
>
> But the thing is, in my old use of System.Web.Mail, I never had this
> problem. Why do I HAVE to specify the host in the new version and I didn't
> have to in the old?
> Alex
Thank you Sharmila for your input.
Hi Alex,
Thank you for your post.
Unlike System.Web.Mail, which was introduced in the 1.0 Framework,
System.Net.Mail is not built upon the CDO/CDOSYS libraries. Instead it is
written from the ground up without any interop. Thus, it is not dependant
upon on other COM libraries. Although some functionality has been removed,
the new System.Net.Mail namespace is much more versatile than the older CDO
dependant System.Web.Mail.
Other than Sharmila's input about specifying the server in code, you can
also config the Host, Credentials and Port properties for SmtpClient by
using the settings in the application or machine configuration files. For
example:
<configuration>
<system.net>
<mailSettings>
<smtp deliveryMethod="network">
<network
host="localhost"
port="25"
defaultCredentials="true"
/>
</smtp>
</mailSettings>
</system.net>
</configuration
Hope this helps. Please feel free to post here if anything is unclear.
Regards,
Walter Wang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
System.Net.Mail versa System.Web.Mail
I am hoping to find out the differences between the
System.Net.Mail and System.Web.Mail.
Can some nice folks post the differences; or some urls which show the
differences?
Great Thanks
FrankHello,
in .NET 1.1, only the System.Web.Mail was available. This implemenation had
fundamental flaws. For example, attachment could only be added from files,
not from Streams.
The .NET 2.0 implementation is System.Net.Mail and is much more flexible and
has a richer featureset.
Best regards,
Henning Krause
"Frank" <frk.won@.gmail.com> wrote in message
news:1175024784.230868.75240@.n59g2000hsh.googlegroups.com...
> Hi,
> I am hoping to find out the differences between the
> System.Net.Mail and System.Web.Mail.
> Can some nice folks post the differences; or some urls which show the
> differences?
> Great Thanks
> Frank
>
On Mar 27, 3:59 pm, "Henning Krause [MVP - Exchange]"
<newsgroups_rem...@.this.infinitec.de> wrote:
> Hello,
> in .NET 1.1, only the System.Web.Mail was available. This implemenation ha
d
> fundamental flaws. For example, attachment could only be added from files,
> not from Streams.
> The .NET 2.0 implementation is System.Net.Mail and is much more flexible a
nd
> has a richer featureset.
> Best regards,
> Henning Krause
> "Frank" <frk...@.gmail.com> wrote in message
> news:1175024784.230868.75240@.n59g2000hsh.googlegroups.com...
>
>
>
>
>
> - Show quoted text -
Hi Mr. Krause,
many thxs
http://www.systemwebmail.com/
http://www.systemnetmail.com/
> On Mar 27, 3:59 pm, "Henning Krause [MVP - Exchange]"
> <newsgroups_rem...@.this.infinitec.de> wrote:
>
> Hi Mr. Krause,
> many thxs
>
On Mar 27, 8:33 pm, Jay Parzych <jimp...@.cox.net> wrote:
> http://www.systemwebmail.com/
> http://www.systemnetmail.com/
>
>
>
>
>
>
>
>
>
>
>
>
>
> - Show quoted text -
great thxs!
Actually System.Net.Mail replaces System.Web.Mail, which is now marked
as obsolete.
Henning Krause [MVP - Exchange] wrote:
> Hello,
> in .NET 1.1, only the System.Web.Mail was available. This implemenation
> had fundamental flaws. For example, attachment could only be added from
> files, not from Streams.
> The .NET 2.0 implementation is System.Net.Mail and is much more flexible
> and has a richer featureset.
> Best regards,
> Henning Krause
>
> "Frank" <frk.won@.gmail.com> wrote in message
> news:1175024784.230868.75240@.n59g2000hsh.googlegroups.com...
>
Gran Andersson
_____
http://www.guffa.com
re:
> Actually System.Net.Mail replaces System.Web.Mail, which is now marked as obsolete
It's only "obsolete" for the .Net Framework 2.0.
It's still supported in the .Net Framework 1.0 and 1.1.
The correct term when a class works in previous
versions, but not in a later one, is "deprecated".
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Gran Andersson" <guffa@.guffa.com> wrote in message news:%23tPjOQWcHHA.4308@.TK2MSFTNGP02.p
hx.gbl...
> Actually System.Net.Mail replaces System.Web.Mail, which is now marked as
obsolete.
> Henning Krause [MVP - Exchange] wrote:
> --
> Gran Andersson
> _____
> http://www.guffa.com
Juan T. Llibre wrote:
> re:
> It's only "obsolete" for the .Net Framework 2.0.
> It's still supported in the .Net Framework 1.0 and 1.1.
Obviously, as System.Net.Mail doesn't exist in framework 1.x.
> The correct term when a class works in previous
> versions, but not in a later one, is "deprecated".
The class is marked as obsolete using the Obsolete attribute. The
correct term for a class marked as obsolete is obsolete. You can also
call it "deprecated" as some other systems use that term for the same thing.
An obsolete class is still working, it's only recommended that it's not
used. As the framework is supposed to be able to run code compiled for
previos versions, classes can't just stop working, at least not until
they have been obsolete for some version updates.
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaol : http://asp.net.do/foros/
> ===================================
> "Gran Andersson" <guffa@.guffa.com> wrote in message news:%23tPjOQWcHHA.43
08@.TK2MSFTNGP02.phx.gbl...
>
Gran Andersson
_____
http://www.guffa.com
re:
> The class is marked as obsolete using the Obsolete attribute.
There's conflicting info on that.
See :
http://msdn2.microsoft.com/en-us/li...system.web.mail(VS.80).aspx
That page says that the classes in the System.Web.Mail namespace have been d
eprecated,
but all its classes have been marked as obsolete.
The namespace is not obsolete. It's deprecated.
That's because it doesn't work in the current version but works in the previ
ous ones.
See:
http://en.wikipedia.org/wiki/Deprecated
"The deprecated feature still works in the current version of the software,
but it may raise error messages or warnings recommending an alternative prac
tice."
and
http://www.w3.org/TR/WD-html40-970917/convent.html
"A deprecated element or attribute is one that has been outdated by newer co
nstructs."
System.Web.Mail can be thought of as "obsolescent", but not "obsolete", sinc
e it still works.
Ymmv, of course.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"Gran Andersson" <guffa@.guffa.com> wrote in message news:eUecQUYcHHA.4820@.TK2MSFTNGP06.phx
.gbl...
> Juan T. Llibre wrote:
> Obviously, as System.Net.Mail doesn't exist in framework 1.x.
>
> The class is marked as obsolete using the Obsolete attribute. The correct
term for a class marked
> as obsolete is obsolete. You can also call it "deprecated" as some other s
ystems use that term for
> the same thing.
> An obsolete class is still working, it's only recommended that it's not us
ed. As the framework is
> supposed to be able to run code compiled for previos versions, classes can
't just stop working, at
> least not until they have been obsolete for some version updates.
>
>
> --
> Gran Andersson
> _____
> http://www.guffa.com
Juan T. Llibre wrote:
> re:
> There's conflicting info on that.
Not at all. It's very simple. There is an Obsolete attribute. There is
no Deprecated attribute. You can mark a class as obsolete, but you can't
mark it as deprecated.
> See :
> http://msdn2.microsoft.com/en-us/li...system.web.mail(VS.80).aspx
> That page says that the classes in the System.Web.Mail namespace have been
deprecated,
> but all its classes have been marked as obsolete.
> The namespace is not obsolete. It's deprecated.
> That's because it doesn't work in the current version but works in the previous on
es.
That is not correct. The classes still work in the current version.
> See:
> http://en.wikipedia.org/wiki/Deprecated
> "The deprecated feature still works in the current version of the software
,
> but it may raise error messages or warnings recommending an alternative pr
actice."
> and
> http://www.w3.org/TR/WD-html40-970917/convent.html
> "A deprecated element or attribute is one that has been outdated by newer
constructs."
> System.Web.Mail can be thought of as "obsolescent", but not "obsolete", since it s
till works.
I think that you are confusing this with something else. Just because
something is obsolete doesn't in any way imply that it would not work
any more.
> Ymmv, of course.
>
>
> Juan T. Llibre, asp.net MVP
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaol : http://asp.net.do/foros/
> ===================================
> "Gran Andersson" <guffa@.guffa.com> wrote in message news:eUecQUYcHHA.4820
@.TK2MSFTNGP06.phx.gbl...
>
Gran Andersson
_____
http://www.guffa.com
System.Net.Mail.SmtpClient Send method causing an Application popu
thanks for your response. I checked my web.config and debug is set to
false. I did some searching on google for the proper reg key to modify
to disable this behavior, but was unsuccessful. Aside from needing to
figure out how to fix this, I'd love to also know *why* it's happening.
All other exceptions thrown in my web app get caught by exception
handlers except this one.
: (There is some unmanaged code stuff going on at the lower levels. My
experience with smtp and the .net controls led me to test locally and I had
to use devmail.net's product to get my sends to work. Even with a detail
trace on what was going on at the port level, I never could sort out my
issue. -greg
<ticketdirector@.gmail.com> wrote in message
news:1145937326.974099.280800@.i40g2000cwc.googlegroups.com...
> Peter,
> thanks for your response. I checked my web.config and debug is set to
> false. I did some searching on google for the proper reg key to modify
> to disable this behavior, but was unsuccessful. Aside from needing to
> figure out how to fix this, I'd love to also know *why* it's happening.
> All other exceptions thrown in my web app get caught by exception
> handlers except this one.
> : (
>
Saturday, March 24, 2012
System.Net.WebClient.DownloadFile doesn't work with http attachments
I have an aspx page at the web server that provides PDF documents for smart
client applications.
Here is the code in aspx page that defines content type:
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition",
"attachment;filename=test.pdf");
I tested the aspx page by using browser and it works just fine.
Now I need to receive that file by using the
System.Net.WebClient.DownloadFile. The problem is that DownloadFile method
returns the following exception:
"Unable to read data from the transport connection: The connection was
closed."
I tested the DownloadFile method to open a direct pdf file like the
following statement:
(new
System.Net.WebClient()).DownloadFile(http://localhost/test.pdf,"c:\\test.pdf
");
It works just fine.
How can I use System.Net.WebClient. DownloadFile to download http
attachments?
Any help would be apprecited,
AlanThe answer is in your question, but you may not recognize it.
An HTTP Request is for a single resource, identified by the URL of the
resource, or in the case of the WebClient, a URI plus a file descriptor. You
have an ASPX page that returns a file with a couple of special Response
Headers in it. Those Response Headers read:
Response.ContentType = "application/octet-stream";
> Response.AppendHeader("Content-Disposition",
"attachment;filename=test.pdf");
This header indicates that the client should prompt the client to make a
second request for the file descriptor specified (text.pdf), and that the
Content-Type of that file is binary.
So, what you have to do is read the Response Headers, and make a second
request for that file specified.
IETF RFC 1806 has a detailed explanation of this Response Header:
http://www.ietf.org/rfc/rfc1806.txt
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
A watched clock never boils.
"A.M-SG" <alanalan@.newsgroup.nospam> wrote in message
news:eY7l5Zu3FHA.1148@.tk2msftngp13.phx.gbl...
> Hi,
> I have an aspx page at the web server that provides PDF documents for
> smart
> client applications.
> Here is the code in aspx page that defines content type:
> Response.ContentType = "application/octet-stream";
> Response.AppendHeader("Content-Disposition",
> "attachment;filename=test.pdf");
> I tested the aspx page by using browser and it works just fine.
> Now I need to receive that file by using the
> System.Net.WebClient.DownloadFile. The problem is that DownloadFile method
> returns the following exception:
> "Unable to read data from the transport connection: The connection was
> closed."
> I tested the DownloadFile method to open a direct pdf file like the
> following statement:
> (new
> System.Net.WebClient()).DownloadFile(http://localhost/test.pdf,"c:\\test.p
df");
> It works just fine.
> How can I use System.Net.WebClient. DownloadFile to download http
> attachments?
> Any help would be apprecited,
> Alan
>
System.Net.WebClient.DownloadFile doesnt work with http attachments
I have an aspx page at the web server that provides PDF documents for smart
client applications.
Here is the code in aspx page that defines content type:
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition",
"attachment;filename=test.pdf");
I tested the aspx page by using browser and it works just fine.
Now I need to receive that file by using the
System.Net.WebClient.DownloadFile. The problem is that DownloadFile method
returns the following exception:
"Unable to read data from the transport connection: The connection was
closed."
I tested the DownloadFile method to open a direct pdf file like the
following statement:
(new
System.Net.WebClient()).DownloadFile(http://localhost/test.pdf,"c:\\test.pdf");
It works just fine.
How can I use System.Net.WebClient. DownloadFile to download http
attachments?
Any help would be apprecited,
AlanThe answer is in your question, but you may not recognize it.
An HTTP Request is for a single resource, identified by the URL of the
resource, or in the case of the WebClient, a URI plus a file descriptor. You
have an ASPX page that returns a file with a couple of special Response
Headers in it. Those Response Headers read:
Response.ContentType = "application/octet-stream";
> Response.AppendHeader("Content-Disposition",
"attachment;filename=test.pdf");
This header indicates that the client should prompt the client to make a
second request for the file descriptor specified (text.pdf), and that the
Content-Type of that file is binary.
So, what you have to do is read the Response Headers, and make a second
request for that file specified.
IETF RFC 1806 has a detailed explanation of this Response Header:
http://www.ietf.org/rfc/rfc1806.txt
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
A watched clock never boils.
"A.M-SG" <alanalan@.newsgroup.nospam> wrote in message
news:eY7l5Zu3FHA.1148@.tk2msftngp13.phx.gbl...
> Hi,
> I have an aspx page at the web server that provides PDF documents for
> smart
> client applications.
> Here is the code in aspx page that defines content type:
> Response.ContentType = "application/octet-stream";
> Response.AppendHeader("Content-Disposition",
> "attachment;filename=test.pdf");
> I tested the aspx page by using browser and it works just fine.
> Now I need to receive that file by using the
> System.Net.WebClient.DownloadFile. The problem is that DownloadFile method
> returns the following exception:
> "Unable to read data from the transport connection: The connection was
> closed."
> I tested the DownloadFile method to open a direct pdf file like the
> following statement:
> (new
> System.Net.WebClient()).DownloadFile(http://localhost/test.pdf,"c:\\test.pdf");
> It works just fine.
> How can I use System.Net.WebClient. DownloadFile to download http
> attachments?
> Any help would be apprecited,
> Alan
System.Net.WebException
I am calling an external web service that returns some data which is being
displayed on my ASP.NET page. This page refreshes every 60 seconds and pulls
the updated data from the web service.
The page works great for a few minutes and then all of a sudden throws the
following error:
System.Net.WebException: Unable to connect to the remote server -->
System.Net.Sockets.SocketException: A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to respond
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState
state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
-- End of inner exception stack trace --
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at fhlb.cmkt.CFM.proxy.NetWireService.NetWireService.getNetWires(getNetWires
getNetWires1) in E:\Projects\CapitalMarkets\CFM\fhlb.cmkt.proxy\Web
References\NetWireService\Reference.cs:line 115
at fhlb.cmkt.CFM.CashFlowMonitor.getNetWiresSecured()
at fhlb.cmkt.CFM.CashFlowMonitor.Page_Load(Object sender, EventArgs e)
Using ASP.NET 2.0 on IIS 6.0 (Windows Server 2003).
Any help will be greatly appreciated.
Thanks!this is normal. it just a timeout on a page request. you need to decide how
to handle it. maybe save the last results and resuse.
-- bruce (sqlwork.com)
"Vijay" wrote:
> Hi,
> I am calling an external web service that returns some data which is being
> displayed on my ASP.NET page. This page refreshes every 60 seconds and pul
ls
> the updated data from the web service.
> The page works great for a few minutes and then all of a sudden throws the
> following error:
> System.Net.WebException: Unable to connect to the remote server -->
> System.Net.Sockets.SocketException: A connection attempt failed because th
e
> connected party did not properly respond after a period of time, or
> established connection failed because connected host has failed to respond
> at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
> SocketAddress socketAddress)
> at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
> at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
> Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketSta
te
> state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
> -- End of inner exception stack trace --
> at System.Net.HttpWebRequest.GetRequestStream()
> at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
> methodName, Object[] parameters)
> at fhlb.cmkt.CFM.proxy.NetWireService.NetWireService.getNetWires(getNetWir
es
> getNetWires1) in E:\Projects\CapitalMarkets\CFM\fhlb.cmkt.proxy\Web
> References\NetWireService\Reference.cs:line 115
> at fhlb.cmkt.CFM.CashFlowMonitor.getNetWiresSecured()
> at fhlb.cmkt.CFM.CashFlowMonitor.Page_Load(Object sender, EventArgs e)
> Using ASP.NET 2.0 on IIS 6.0 (Windows Server 2003).
> Any help will be greatly appreciated.
> Thanks!
Thanks for the quick reply Bruce.
Is it a timeout on the webpage that is calling the web service or is it a
timeout that is occuring on the web service? What does it mean when you say
"save the last results and reuse" ?
Thanks!
Vijay
"bruce barker" wrote:
> this is normal. it just a timeout on a page request. you need to decide ho
w
> to handle it. maybe save the last results and resuse.
> -- bruce (sqlwork.com)
>
> "Vijay" wrote:
>