M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

ConnectionString and config

In this tutorial we will see how to specify the connection string and how to get data from the config file.
Like all ASP.Net projects, M# uses the standard Web.config file for storing the connection string of your project. This file also allows you to specify your custom application settings.

Connection String

The Connection string specifies information about a data source and the means of connecting to it. It is stored in the Web.config file of your project as follows:

In the example above our HelloWorld project is a project using a TDD database mode, which means we have three different databases in our project and the current one is HelloWorld.AdHocTest.
For more information about Database mode please refer to Chapter 1 - Hello World.

Config

The Config class allows you to get data from the Web.config file. In this file you can put static data that will never change, like the key of a third party library, the URL of a payment gateway, ect ...
The method Get() helps you to access this data and has two overloads:

Here is an example of how to use those overloads:

You may also be interested by some other methods: