C# - How To Get The SMTP Settings Automatically From Web.config
May 4, 2010
I noticed that we always just are like:
SmtpClient mSmtpClient = new SmtpClient();
// Send the mail message
mSmtpClient.Send(mMailMessage);
And the only place the credentials are set are in web.config:
<system.net>
<mailSettings>
<smtp>
<network host="xxx.xx.xxx.229" userName="xxxxxxxx" password="xxxxxxxx"/>
</smtp>
</mailSettings>
</system.net>
So my question is, how does it automagically get them out?
View 3 Replies
Similar Messages:
Mar 26, 2010
I want to send mail using SMTP settings. And it will not be configured in web.config. I want to set the SMTP settings at run time. How I can do this?
View 7 Replies
Sep 1, 2010
We are experiencing some strange behaviour on one of our ASP.NET web servers (Windows 2003 64-bit). After some activity, two third-party controls are unable to run correctly. One is log4net (it does not write error messages out) and the other is a menu control (it displays eval message instead of picking up its license). The one common thread is that both controls pick up their config from external config files (linked to from web.config).
Just wondering if anyone has any thoughts on this or experienced this in any way. Is it related to file/folder rights? The server has been running fine for a while and just started exhibiting this behaviour. Perhaps it occurs around the time the worker processes are recycled.
View 1 Replies
Jul 8, 2010
I have many Connection strings in my web.config file. I also have a "dataConfiguration" setting in the same file which specifies what database my app connects to.
How do I read the "defaultDatabase" setting / section from the, see below xml file.
<configuration>
<configSections> [code]....
View 2 Replies
May 26, 2010
i've been googling this for two days so here it both the error and the webconfig code.i directed the aspnet 2.0 exe to the application name/database
the problem is when the user tries signing up this error comes up, but the kicker is the user is place into the database ?The specified string is not in the form required for an e-mail address.
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.FormatException: The specified string is not in the form required for an e-mail address.
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: [FormatException: The specified string is not in the form required for an e-mail address.]
System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName) +1128747
System.Net.Mail.MailAddress.ParseValue(String address) +240 [code]...
View 1 Replies
Jan 19, 2011
I have a .NET 4 class library project, which is used by multiple web projects. In this class library I need to get a DB connection string and it needs to be the same for all the web projects. Currently I've got it as a setting in each web.config file, but this is not ideal. Is there any way I can have that configuration stored with the DLL, but still allow it to be modified at runtime (ie. hardcoding the connection string is out)?
App.config seems to be generally ignored for a DLL, even though it does get renamed to assemblyname.dll.config and copied to the bin directory for the web. I tried making it an "application setting" (ie. using the auto-generated class derived from System.Configuration.ApplicationSettingsBase) and this appeared to work, but changing the value in the DLL .config file at runtime had no effect, so I suspect it's really just using the hardcoded default value of the setting.
View 3 Replies
Mar 18, 2010
i need to encrypt the SMTP settings for my web site, i tryed the aspnet_regiis.exe pe... but i got an error this is not a valid virtual dir. i have the website on the C drive on my development machine, i have encrypted the connectionsettings via .net code but cant finde a solution for the smtp node can i encrypt the smtp in development pc or it hacse to be deployed first?
View 5 Replies
Nov 25, 2010
I can't seem to find this answer anywhere on google or stackoverflow, even though I'd thought it would've been an easy thing to do.
I want to understand how the system.web authorization tag on the web.config works, and what exactly each attribute and property does.
For instance, what does
<system.web>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
</system.web>
Specifically what I want to do is to disallow access to most of the site for unauthenticated users, allow access to some of the site for authenticated users who belong to a certain role, and allow full access to users from a second role.
View 2 Replies
May 23, 2010
This might sound a bit dumb. I always had this impression that web.config should store all settings which are suspect to change post-build and setting.settings should have the one which may change pre-build.but I have seen projects which had like connection string in setting.settings. Connection Strings should always been in web.config, shouldnt it?I am interested in a design perspective answer.Just a bit of background:My current scenario is that I am developing a web application with all the three tiers abstracted in three separate visual studio projects thus every tier has its own .settings and .config file.
View 2 Replies
Jun 6, 2010
I'm starting to consider creating a class library that I want to make generic so others can use it. While planning it out, I came to thinking about the various configuration settings that I would need. Since the idea is to make it open/shared, I wanted to make things as easy on the end user as possible. What's the best way to setup configuration settings without making use of web.config/app.config?
View 3 Replies
Feb 28, 2010
I want to know what best practice is for accessing settings in config file when you have dev/test/production types.
If you have different config for each type when you publish a ASP.NET website doesn't the config get copied as well??
View 3 Replies
Feb 3, 2011
Is it possible to configure your web.config file of your asp.net website to use different settings for users accessing the site via HTTPS?
(eg. I need to have validateRequest attribute for https access set to false, but for internal access (using http) set to true...)
View 2 Replies
Sep 22, 2010
I am designing a web application for Leave Application of our faculties. There is a form in my website which represent the existing paper-back leave application form. Users(faculties) have to fill-up this web form and after validation an email will be send to the email address of our principal/hod. I hope that email address(s) will be provided to our group members. Now I want to know that what will be the required configuration of the web.config file? I found this blog ScottGu's Blog. Here the given configuration is:
[Code]....
But I think this is not acceptable for my project as the smtp from="test@foo.com", userName, password are unknown to me. So what should I do. Am I able to understand my requirement to you?
View 4 Replies
Aug 10, 2010
whats a good way to test the settings (especially keys) in web.config? I think its not really testable with NUnit, or is it?Example: <add key="SomeKey" value="SomeValue" />
View 2 Replies
Nov 11, 2010
I've created a web page and it contains some settings value in web.cofig for example images.So i want to give the path of images in Web.Config file and file name in that particular image src. I wanted to read that settings only in aspx page not in codebehind. For example Web.Config: <add key="ImagePath" value=[URL]> and in my aspx page, <img id="ImgHeader" runat="server" src="<%ConfigurationManager.AppSettings["ImagePath"]%>" />
View 2 Replies
Oct 30, 2010
I have an ASP.NET site which uses a 3rd party activeX control. I have to pass a few parameters to the OBJECT tag in the HTML page. If i hardcode these parameters into the HTML everything works.
I would like to place the parameters in my web.config with app settings "key/value" pairs.
My problem is i cannot read the app key setting in the HTML markup to succesfully pass them in as parameters. I can read them fine from server side code behind.
What's the correct way to read these settings in the client side HTML markup ?
View 4 Replies
Aug 18, 2010
I'm trying to use the following command:
Dim xmlFilePath As String = _
System.Configuration.ConfigurationManager.AppSettings("XmlFilePath")
to retrieve the following setting:
<applicationSettings>
<MySolution.WebProject.My.MySettings>
<setting name="XmlFilePath" serializeAs="String">
<value>C:ASP.NETFolderMessageLog</value>
</setting>
</MySolution.WebProject.My.MySettings>
</applicationSettings>
However, xmlFilePath shows up as Nothing after that line of code is run. What's the correct code to get a setting out of the web.config file in an ASP.NET application?
NOTE: Although you can add keys individually to the <appsettings> tag, I'm trying to figure out how to use it with the "Settings" tab in the project's properties.
View 2 Replies
Jul 21, 2010
There are a bunch of hardcoded strings in a ASP.NET application.
eg. string constSetting = "XYZ";
There are a LOT of them. Is there a tool/plugin for Visual Studio 2008 to refactor it in such a way that the constant string goes into web.config and the above line gets replaced by the retrieved string from web.config app settings?
View 2 Replies
Feb 15, 2010
What it best location to store various configuration settings of a web site modules. Creating class (that inherit ConfigurationSection) that map the settings in web.config file?Or creating some DAL and BLL clases that work with database?
View 5 Replies
Feb 9, 2010
My asp.net app has is using a web.config for common configuration. I also have a section that maps some data objects to connection strings, and that section is going to be couple thousand of lines. I want to move that section to another config file "dataMappings.config", so I don't bulk up web.config - is there a standard mechanism of accessing that config file?
View 1 Replies
Nov 12, 2010
I've been thinking about this for a couple days but still would like some feedback on the best way to go about this:
I have multiple sites (domains) that will be running the same code. However, there are a couple settings I have in the appsettings web.config file which are relative to each site. (ie: defaultSiteTitle, emailFromAddress, etc).
I would like to deploy this application in only one location (folder) and point the domains in IIS to that one directory.
To do this, I believe I cannot use the web.config file to hold these settings...
So, I decided to make a SiteSettings.xml file and load the site settings in there:
<sites>
<oSite domain="abc.com" defaultSiteTitle="This is Site ABC" emailFromAddress="info@abc.com" />
<oSite domain="xyz.com" defaultSiteTitle="This is Site XYZ" emailFromAddress="info@xyz.com" />
</sites>
So when I need to access the site settings I just call a function in my datalayer that reads this xml file and via the httpRequest I pass it it determines which site settings to use.
Okay, that works when I call it from a page where I have the httpRequest...
Howver, now when I'm into some business layer functions say sendEmail and I need to find the emailFromAddress from the SiteSettings.xml file, I don't have the httpRequest. I know I could probably hack something together and pass it someway...
But I'm trying to figure out the best way to do this...
I don't really want to store it into session.
Is it possible to tell IIS what web.config file to look at, if I had multiple web.config files? (I don't think this is possible).
View 2 Replies
Jun 17, 2010
I have this portion of my web.config file;
[Code]....
I need to be able to retrieve the value of "from" in my application. How do I read this value into my code?
View 3 Replies
Aug 4, 2010
I thought I would put those settings into Cache and then invalidate them if the web.Config file changes. Reading some articles make it seem that this is completely unnecessary.
View 1 Replies
Jan 25, 2011
I posted a question on stack overflow about how partial view output caching issues:
[code]....
It errors out if you try to use a cache profileIf you turn off caching in the web.config. IT STILL CACHESThese settings work fine for normal view, just not partial view...
View 5 Replies
Nov 15, 2010
In my ASP.NET application I set
<system.web><globalization culture="pl-PL" uiCulture="pl-PL" />
to have numbers and dates in this culture.
Surprisingly I noticed that methods invoked from job scheduler (Quartz library) use en-US? Why is that?
View 1 Replies