Is there a simple way to get a property value of <smtp></smtp> in web.config?

I know I can use the ConfigurationManager.AppSettings["VersionOfWebSite"] code to get value of the key VersionOfWebSite
Now I hope to get the value of from property in <smtp> (the value is user@hellocw.com), how can I do? Thanks!


//--------------------------Web.Config--------------------------------------
<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
 
  <system.net>
    <mailSettings>
      <smtp from="user@hellocw.com">
        <network host="mail.hellocw.com" password="password" userName="username" />
      </smtp>
    </mailSettings>
  </system.net>

  <appSettings>
     <add key="VersionOfWebSite" value="1.0"/>
  </appSettings>
 
</configuration>
//--------------------------Web.Config--------------------------------------


SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip files

SuperCool Random Number Generator
0
mycwcgr
5/4/2007 1:14:22 AM
asp.net.config-deploy 12495 articles. 0 followers. Follow

5 Replies
746 Views

Similar Articles

[PageSpeed] 9

 Hello mycwcgr,

Check out the following link: http://community.strongcoders.com/blogs/ryan/archive/2006/03/25/625.aspx


Hope this helps. 


www.hopeasp.net
0
CSharpSean
5/4/2007 5:34:26 AM

It works well in local PC, but after I upload to remote hosting , I get the following error when I try to access it. does it mean your code can't work in any case?  can I read web.config in this case?

 

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

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:


[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +59
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +678
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +114
   System.Configuration.Internal.InternalConfigHost.StaticOpenStreamForRead(String streamName) +80
   System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForRead(String streamName, Boolean assertPermissions) +115
   System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForRead(String streamName) +7
   System.Configuration.Internal.DelegatingConfigHost.OpenStreamForRead(String streamName) +10
   System.Configuration.UpdateConfigHost.OpenStreamForRead(String streamName) +42
   System.Configuration.BaseConfigurationRecord.InitConfigFromFile() +443

 

 


SuperCool Multiple ZIP - A utility to unzip multiple files and work with multiple zip files

SuperCool Random Number Generator
0
mycwcgr
5/4/2007 10:33:59 AM
Reply:

Similar Artilces:

connectionstrings and web.config // login failed for user '<<domain>>\<<servername>>$'
It seems that the account mentioned <>\Server$ is the NTAUTHORITY\NETWORKSERVICE I read some posts on the net about .NET 1.1 that involved changing your machine.config.. not an option I like because then the webserver of my hosting company needs to do that to. Visual studio 2005 makes for the dataset a code behind file <>.designer.cs. I did change the connectionstring from my commands to a connectionstring with sql credentials. But it doesn't update everything. My logic was that when i remove the connectionstrings from the app.config or web.config they don't exist anymore so I ...

web.config <healthMonitoring> <bufferModes> <add ... regularFlushInterval="Infinite"> no longer legal?
Why does some documentation say that when adding a bufferModes item to one's health monitoring, that "Infinite" is a legitimate value for the regularFlushInterval attribute, but now the web.config schema apparently says it's not a legal value?  Did something change in what's permitted?  Did this once work but no longer does?  Or does it still work in spite of the warning message that says "the 'regularFlushInterval' attribute is invalid"?  I believe "Infinite" is a valid value.  See http://msdn.microsoft.com/en-us/l...

Web.config
Hi, i'm just woundering - in the web.config on TheBeerHouse are <theBeerHouse> tags, how are these defined? I'm trying to develop a forum only, microsoft acces and VB version of the site with a completly different layout lol. I can't seem to work out why I get this error:  Server Error in '/Forum' Application. -------------------------------------------------------------------------------- Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error d...

>>>> Heads up <<<<
I just got a warning from Norton that "PamelaSetup-Basic.exe" has a virus in it. The name is "VirusBurst" Luckily, I did not install this software and Norton's quarantined it so I could delte it, which I have done. Symantec has not completed analysis of this particular piece of garbage but it did catch the sig. If you have installed Pamela, you may be in trouble. Duffy wrote: > I just got a warning from Norton that "PamelaSetup-Basic.exe" has a virus > in it. The name is "VirusBurst" > > Luckily, I did not install...

nsWebBrowserPersist gives me <window>, not <html>
Is there supposed to be a way to use the saveDocument method in nsIWebBrowserPersist, from JavaScipt, that can give one the page source? I have also seen this question prefaced with "I am a <insert word that rhymes with ruby>, but...", which is probably a good way to not get an answer. Well, I am not new. Do I understand everything I see in FF, or know where _all_ the documentation is? No. Do I have those dragon-shaped scars on my forehead that people outside Mountain View get as they bang their head against this stuff? Yes. I do. I am using the nsIWebBrowse...

<%@ Register %> vs. <controls> in web.config
Is either of the two methods for user controls preferred from the point of view of memory and overhead? 1.<%@ Register TagPrefix="tgPrfxName" TagName="header" Src="~/User Controls/Header.ascx" %> in each page or2.<add tagPrefix="tgPrfxName" src="~/User Controls/Header.ascx" tagName="header"/> in the web.config There is not a memory or compilation difference between the two... But the "controls" method is much cleaner than a "Register" tag on every page :P Peace,-Timothy Khourihttp://www.SingingEels.com/Developer / Architect / Author...

>>>> ROOT Exploit in SAMBA <<<<<<
"A flaw has been detected in the Samba main smbd code which could allow an external attacker to remotely and anonymously gain Super User (root) privileges on a server running a Samba server. This flaw exists in previous versions of Samba from 2.0.x to 2.2.7a inclusive. This is a serious problem and all sites should either upgrade to Samba 2.2.8 immediately or prohibit access to TCP ports 139 and 445." http://us3.samba.org/samba/samba.html Binaries are available from Samba for RedHat, and some other distributions. So far as I can tell, the RedHat update mirrors I norm...

>>>> CAPITALS GAMES <<<<
.. ~~~!!!~~~ ================================================== ================================================== CLICK HERE TO ENTER: >>> http://web-paradise.cn/3/capitals-games <<< ================================================== ================================================== .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ....

C<< >> vs C<< >> vs C<< x >>
Ugh. So we all know that there's this syntax for formatting codes (n=E9s "interio= r sequences") like C<< x >>. And that tokenizes as three tokens: "C<< ", open-C code "x", content " >>" close-code matching the C open-code And this is explicated by what I wrote in perlpodspec where I say that such a code... * starts with a capital letter (just US-ASCII [A-Z]) followed by two or more "<"'s, one or more whitespace characters, * any number of characters * one or more whit...

>>>> BUY RAM <<<<
.. ~~~*@@@*~~~ ================================================== ================================================== ENTER HERE: >>> http://web-for-you.cn/about/buy-ram <<< ================================================== ================================================== .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ...

When will <namespaces> under <pages> be added in web.config?
 I have been working ASPnet 2.0 for the past 2-3 years and just getting started with ASPnet 3.5.Recently I noticed some of my ASPnet websites have <namespaces> tags in the web.config file;but some don't.  Why?  In what kinds of website, we will have these, e.g. <add namespace="System"/>while some have none?  Where can I find infor on how namespaces are added?  Thanks.  <pages><namespaces><clear/><add namespace="System"/><add namespace="System.Collections&q...

Lists in .net
Like a good AKA accessible app building developer, my application's navbar is controlled with CSS and using <ul> and <li> I just have the code in the HTML display and it works fine when everything should be visible, however, I need to restrict some users from viewing certain navbar links based on their security levels.  How do I hide the list items that need to be hidden? TIA hello! give them ids and runat="server" attribute. then in code behind set the Visible property to false. orzeh code less, think more! Okay, I tried putting the link as a link bu...

What is the difference betwen <appSettings> and <connectionStrings> in the web.config file?
 I have seen connection strings in both the <appSettings> and the <connectionStrings> elements in web.config files.  I don't understand when i should use which one(since I have seen connetion strings in both of them) or their relationship with each other(or if they have a relationship with each other).   I understand some of the more obvious things that their names imply.  A deeper understanding would be helpful though. Can someone please explain or provide a link to a good article on this? Thanks. Thanks to everyone that has ever helped me with any p...

Using <authentication> tag within <location> tag of web.config
Is it possible to use the <authentication> tag within a <location> tag? I am getting the following error when attempting to do so: Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. I assume it is not possible but I don't want to create a Virtual Directory. Basically, I just want to redirect unauthorized users of a subdirectory to an not authorized page if they are not listed in the <allow users...

Web resources about - Is there a simple way to get a property value of <smtp></smtp> in web.config? - asp.net.config-deploy

Resources last updated: 12/21/2015 5:23:43 PM