Archive

Posts Tagged ‘read’

Read/Write Section from/into Web.config in Asp.net

Many times, we need to read sections from web.config or write into web.config.

I have a requirement where i need to write an section in web.config that points to another config file.

Below is the code where “abc” is the section

Configuration objConfig = WebConfigurationManager.OpenWebConfiguration(“~”);
ConfigurationSection section = objConfig.Sections[“abc”];
string str = “abcdef”;
section.SectionInformation.SetRawXml(str);
objConfig.Save();

The above code will read “abc” section and write the content in str.

For Reading Appsettings from web.config, below is the code

Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); AppSettingsSection appSettings = (AppSettingsSection) config.GetSection(appSettings);

string[] appKeys = appSettings.Settings.AllKeys;

for (int i = 0; i < appSettings.Settings.Count; i++)

{

Response.Write(appSettings.Settings[appKeys[i]].Value);

Response.Write(“<BR>”);

}

CRUD(Create/Insert/Update/Delete) with Asp.net MVC Framework, Linq To Sql (.dbml)

June 26, 2009 1 comment

This article will explain you how to create, read, insert, update, delete operations with asp.net mvc with Linq To Sql (.dbml).

Very nice article who are beginners with asp.net mvc framework.

http://blogs.microsoft.co.il/blogs/bursteg/archive/2009/02/03/create-a-strongly-typed-crud-ui-with-asp-net-mvc-rc.aspx