Trying to make an ASP.net program

The value of the property 'port' cannot be parsed.

Page 1 of 1

4 Replies - 2501 Views - Last Post: 23 June 2010 - 03:40 PM Rate Topic: -----

#1 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 346
  • Joined: 26-May 09

Trying to make an ASP.net program

Posted 21 June 2010 - 01:28 PM

My program gets data from Paypal, and upon validation it should send an email to the user. When testing on my computer it works, but once copied to my server I get this error:
The value of the property 'port' cannot be parsed. The error is: is not a valid value for Int32.

It is here: http://www.graphicport.net/reg/

When clicking the button there is that error. But like I said it works and email is sent when testing on my computer... Can you please help me out?


 Sub SendMsg(ByVal First As String, ByVal Last As String, ByVal email As String, Optional ByVal Invalid As String = "xxxx")

        Try

            Dim mail As MailMessage = New MailMessage()
            mail.To.Add(email)
            'mail.To.Add("")
            mail.From = New MailAddress(Invalid)
            mail.Subject = "xxx"

            Dim Body = "xxxx"

            Dim InvalidBody = "xxx " 

            mail.Body = Body

            If Button1.Visible = True Then mail.Body = InvalidBody

            mail.IsBodyHtml = True
            Dim smtp As SmtpClient = New SmtpClient()
            smtp.Host = "smtp.gmail.com"
            smtp.Port = "587"
            smtp.Credentials = New System.Net.NetworkCredential("xxxx", "xxxxx")
            smtp.EnableSsl = True
            smtp.Send(mail)

        Catch ex As Exception

            Label1.Text = ex.ToString

        End Try

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Try

            SendMsg("xxxx", "xxxxx", "xxxx", TextBox1.Text)

        Catch ex As Exception

            Label1.Text = ex.ToString

        End Try



Is This A Good Question/Topic? 0
  • +

Replies To: Trying to make an ASP.net program

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,960
  • Joined: 21-March 08

Re: Trying to make an ASP.net program

Posted 21 June 2010 - 01:33 PM

I am not sure how this worked on your machine since Port is an Integer property and you are assigning a string value to it.

change this..
smtp.Port = "587"



to this...
smtp.Port = 587


Was This Post Helpful? 0
  • +
  • -

#3 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 346
  • Joined: 26-May 09

Re: Trying to make an ASP.net program

Posted 21 June 2010 - 01:39 PM

Thanks for the reply, I just tried that and still get the same error. I even had that error before specifying the port. I added the port info thinking it would help.

Line 119 is this
Dim mail As MailMessage = New MailMessage()


System.Configuration.ConfigurationerrorsException: The value of the property 'port' cannot be parsed. The error is: is not a valid value for Int32. (D:\Hosting\4610682\html\web.config line 149) at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult) at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission) at System.Configuration.BaseConfigurationRecord.GetSection(String configKey) at System.Web.HttpContext.GetSection(String sectionName) at System.Web.Configuration.HttpConfigurationSystem.GetSection(String sectionName) at System.Web.Configuration.HttpConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String configKey) at System.Configuration.ConfigurationManager.GetSection(String sectionName) at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName) at System.Net.Configuration.SmtpSectionInternal.GetSection() at System.Net.Mail.SmtpClient.get_MailConfiguration() at System.Net.Mail.MailMessage..ctor() at _Default.SendMsg(String First, String Last, String email, String Invalid) in D:\Hosting\4610682\html\reg\Default.aspx.vb:line 119

Line 149 of web config is this:

<mailSettings>
<smtp from="">
<network host="" password="" port=""
userName="" />
</smtp>
</mailSettings>

This post has been edited by vbnet9: 21 June 2010 - 01:58 PM

Was This Post Helpful? 0
  • +
  • -

#4 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 346
  • Joined: 26-May 09

Re: Trying to make an ASP.net program

Posted 21 June 2010 - 02:11 PM

<network host="" password="" port=""

I changed port to the default 25 and now I get this error:

System.Security.SecurityException: Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) at System.Security.CodeAccessPermission.Demand() at System.Net.Mail.SmtpClient.set_Port(Int32 value) at _Default.SendMsg(String First, String Last, String email, String Invalid) in D:\Hosting\4610682\html\reg\Default.aspx.vb:line 143 The action that failed was: Demand The type of the first permission that failed was: System.Net.Mail.SmtpPermission The Zone of the assembly that failed was: MyComputer


I can run the program on my computer, but not the server. What do I need to fix?
Was This Post Helpful? 0
  • +
  • -

#5 vbnet9  Icon User is offline

  • D.I.C Regular

Reputation: 12
  • View blog
  • Posts: 346
  • Joined: 26-May 09

Re: Trying to make an ASP.net program

Posted 23 June 2010 - 03:40 PM

Is this something I have to talk to the web host about? Or is there some way to grant the correct security access?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1