Here some related examples...
Create or change Login settings...
We can simplify our code by using the Web.config. It's very easy to change the mode. If you need "form" authentication mode, see below...
Should be Inside the
< mode="Forms">
< timeout="30" loginurl="~/login.aspx">< /forms>
< /authentication>
Then we should indicate location(What is the directory or pages not allow to access to other out side users) and authorization (Who has allowed to access to the secure pages) properties.
see below...
< path="Cp" allowoverride="true">
<>
<>
< users="?">
< /authorization>
< /system.web>
< /location>
Create database connection...
You can create database connection in Web.config using below code. Then you can use this connection anywhere. How easy........?
Out side the
"
<>
< name="DemoConnectionString" connectionstring="Data Source=.;Initial Catalog=Demo;User ID=sa;Password=sa" providername="System.Data.SqlClient">
< /connectionStrings> "
Set image path...
When you are going to upload images to the website, then you can set image path using in the web.config file.
Outside the
"
<>
< key="ItemImagePath" value="D:\Projects\My Project\www.demoproject.com\images">
< /appSettings> "
Support e-mailling...
System.Net.Mail allowed us to send and recieve email prety handy way in the .net framework. Here some code examples of C# and web.config configuration for email settings.
ButtonClik event handler code
MailMessage message = new MailMessage();
message.From = new MailAddress(" sender@domainName ");
message.To.Add(new MailAddress(" recipient e-mail adress1 "));
message.To.Add(new MailAddress(" recipient e-mail adress2 "));
message.CC.Add(new MailAddress(" carboncopy@domainName "));
message.Subject = "This is my subject";
message.Body = "This is the content";
SmtpClient client = new SmtpClient();
client.Send(message);
Then you should set the Web.config configurations for e-mails.
Web.config code...
< from="sahan@inzeek.com">
< host="mail.inzeek.com" port="25" username="sahan" password="sahan" defaultcredentials="true">
smtp="">
mailsettings="">
0 comments:
Post a Comment