Sie sind auf Seite 1von 3

Configuration Settings:

Configuration settings are used to perform the global settings required to be implemented for group of
websites or for a single website / group of web pages within a website.

We can perform these settings in configuration files.

These are in xml format

Always configuration files are start with a tag called “<Configuration>”

Types of configuration files

Machine.Config

Web.Config:

Used to change the settings for a single website / group of webpages.

There can be max of only one web.config file present in root folder of the website. Each subfolder of the
website can be max of only one web.config.

<appSettings> tag in web.config:

Used to create global variable & to store the data i.e required to be stored commonly in group of
webpages.

<add> tag is used to add some value to a key which we can use globally. This tag contains a subtag called
key & value.

When we create appsettings then internally one collection table will be created internally with the name
appSettings.

Ex:-

<appSettings>
<add key="connectionstring" value="server=vamsi;uid=sa;password=sa123" />
<add key="cminbal" value="3000"/>
</appSettings>

How to access appSettings value:

We have to import a name space called “using System.Configuration;” namespace

Ex:-

if(!IsPostBack)
{
lblMinBalance.Text = "Your Account MinBal is : " +
ConfigurationManager.AppSettings["cminbal"];
}
Ex:

try
{
SqlConnection con = new
SqlConnection(ConfigurationManager.AppSettings["connstring"]);
con.Open();

Working with ConnectionStrings Tag in web.config:

Connection strings tag iin web.config is used to store connection string alues with in the web.config file.

It is included in 2.0 version

This tag is having a sub tag called <add> in this we are having 2 attributes name and connectionString

Ex:-

<connectionStrings>
<add name="sqlcon" connectionString="server=DESKTOP-
70UN8IR\MSSQLSERVER1;uid=sa;password=sa123;database=sample;"/>
</connectionStrings>

All this connectionstrings are stored in a collection table called “connectionsStrings”

try
{
string conn =
ConfigurationManager.ConnectionStrings["sqlcon"].ConnectionString;
SqlConnection con = new SqlConnection(conn);
con.Open();
Web Pages are of 2 types

1. Restricted Pages
2. Non Restricted Pages

Security Implementation in Asp.NET:-

1. Authentication
It is a process of checking whether user credentials (userid & password ) are valid or not.
If user credentials are valid user will be given a ticket known as authentication ticket. Always this
authentication ticket will be in the form of cookie.

2. Authorization
It is the process of checking weather an authenticated user has an authorization to access
restricted pages are not.

Types of Authentication Models

1. Windows (default)
2. Passport
3. Forms