2014-11-24 49 views
0

這是我的情況。我們是一家制造工廠。當有人向維修部門提交有關機器問題的信息時,他們必須在2個部門之間進行選擇。電子郵件有一個通用的收件人列表,但選項會發送給其他人。發送電子郵件時覆蓋我的web.config

我有它,我可以更改或添加/刪除在web.config中的普通電子郵件列表,但選擇一個部門時,沒有任何變化都會從可選部門的郵件列表中添加或刪除的人的問題。我找不到它被覆蓋的地方。

這是aspx.cs形式:

namespace ContactForm 
{ 
public partial class ContactForm : System.Web.UI.Page 
{ 
    public ContactForm() 
    { 
    } 




    protected void SubmitBtn_Click(object sender, EventArgs e) 
    { 
     if (Page.IsValid) 
     { 
      System.Configuration.Configuration config 
       = WebConfigurationManager.OpenWebConfiguration(base.Request.ApplicationPath); 
      AppSettingsSection appSettings = (AppSettingsSection)config.GetSection ("appSettings"); 

      string emailHost = appSettings.Settings["EmailHost"].Value; 
      string fromAddress = appSettings.Settings["FromEmailAddr"].Value; 
      string toAddress = appSettings.Settings["ToEmailAddr"].Value; 

      SmtpClient smtpClient = new SmtpClient(emailHost); 

      // Default in IIS will be localhost 
      //smtpClient.Host = "localhost"; 

      //Default port will be 25 
      smtpClient.Port = 25; 

      MailMessage message = new MailMessage(); 
      message.IsBodyHtml = false; 
      message.Priority = MailPriority.High; 
      message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; 

      try 
      { 
       message.Subject = "Maint Request: " + this.subjectBox.Text; 
       message.Body = "From: " + nameBox.Text.Trim() + "\n" + "\n"; 
       message.Body += "Created At: " + txtDate.Text + "\n" + "\n"; 
       message.Body += "Department: " + listDepartment.SelectedItem.Text + "\n" + "\n"; 
       message.Body += "Priority: " + listPriority.SelectedItem.Text + "\n" + "\n"; 
       message.Body += "Machine Area: " + txtMachineArea.Text + "\n" + "\n"; 
       message.Body += "Machine Number: " +txtMachineNumber.Text + "\n" + "\n"; 
       message.Body += "Problem description: " + txtQuestion1.Text; 
       toAddress += "[email protected]"; 
       if (listDepartment.SelectedItem.Text == "Option1") 
       { 
        toAddress += ", [email protected], [email protected]"; 
        //toAddress += ", [email protected]"; 
       } 
       else if (listDepartment.SelectedItem.Text == "Option2") 
       { 
        toAddress += ", [email protected]"; 
     //toAddress += ", [email protected]"; 

這是web.config文件

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
<system.webServer> 
<defaultDocument> 
    <files> 
    <clear /> 
      <add value="index.aspx" /> 
    <add value="index.html" /> 
    <add value="Default.htm" /> 
    <add value="Default.asp" /> 
    <add value="index.htm" /> 
    <add value="iisstart.htm" /> 
    <add value="default.aspx" /> 
    </files> 
</defaultDocument> 
<staticContent> 
    <mimeMap fileExtension=".mp4" mimeType="video/mp4" /> 
    <mimeMap fileExtension=".ogv" mimeType="video/ogg" /> 
    <mimeMap fileExtension=".ogg" mimeType="application/ogg" /> 
    <mimeMap fileExtension=".webm" mimeType="video/webm" /> 
    <mimeMap fileExtension=".oga" mimeType="audio/oga" /> 
    <mimeMap fileExtension=".f4v" mimeType="video/mp4" /> 
</staticContent> 
</system.webServer> 
<appSettings> 
<add key="MyEmailAddr" value="[email protected]" /> 
<add key="ToEmailAddr" value="[email protected]" /> 
<add key="EmailHost" value="mail.webpage.com" /> 
<add key="FromEmailAddr" value="[email protected]" /> 
</appSettings> 
<system.net> 
<mailSettings> 
    <smtp from="[email protected]"> 
    <network host="mail.webpage.com" /> 
    </smtp> 
</mailSettings> 
<!-- 
    <mailSettings> 
     <smtp deliveryMethod='SpecifiedPickupDirectory'> 
      <specifiedPickupDirectory pickupDirectoryLocation="c:\maildrop" /> 
     </smtp> 
    </mailSettings>--> 
</system.net> 
<connectionStrings /> 
<system.web> 
<!-- 
     Set compilation debug="true" to insert debugging 
     symbols into the compiled page. Because this 
     affects performance, set this value to true only 
     during development. 
    --> 
<compilation debug="true" /> 
<!-- 
     The <authentication> section enables configuration 
     of the security authentication mode used by 
     ASP.NET to identify an incoming user. 
    --> 
<authentication mode="Windows" /> 
<!-- 
     The <customErrors> section enables configuration 
     of what to do if/when an unhandled error occurs 
     during the execution of a request. Specifically, 
     it enables developers to configure html error pages 
     to be displayed in place of a error stack trace.  --> 
    <customErrors mode="Off" /> 
</system.web> 
</configuration> 

如果你們能在這裏找到任何東西,告訴我是怎麼回事,什麼正在壓倒我所做的任何改變,這將是驚人的。我絕不是程序員,幾個月前剛接手IT,似乎整件事都是用C#編寫的,需要添加一些電子郵件到列表中

+0

重新部署它,因爲你不是一個程序員,我要問的很明顯,你需要重新編譯代碼隱藏(以下簡稱「aspx.cs文件」),你做後你的改變?我假設你正在改變行'toAddress + =「,[email protected],[email protected]」;'等是正確的? – user469104 2014-11-24 19:04:10

+0

你是對的。我嘗試將電子郵件添加到列表選擇下的toAddress行。我已經嘗試了兩種選擇,但不管我做什麼,它總是會轉到原始cs上的同一個人。我甚至會從上面的CS刪除它們,但它繼續去他們母雞執行測試 – Individual101 2014-11-24 19:09:47

+0

這是部署爲ASP.NET「Web項目」或爲ASP.NET「Web應用程序項目」?您正在修改的文件與編譯的代碼相關的位置在哪裏?如果這是一個ASP.NET Web應用程序項目,那麼在更改.cs文件後需要重新編譯/重新部署該項目。在更改代碼後你是否重新編譯/重新部署? – user469104 2014-11-24 19:43:02

回答

0

我通過查找網頁上的網頁解決了這個問題虛擬主機服務器和卸載的頁面,並與變化