Category: ASP.NET
How to read a connection string from web.config file in ASP.NET ?
Assume that you have a connectionstring configured in the web.config file of your ASP.NET application and you wish to read it using C# within your application. How to read a connection string from web.config file in ASP.NET ? You can easily do that using the ConfigurationManager class defined in the System.Configuration namespace. 1. Ensure that the System.Configuration assembly is referenced in your project. 2. Add…
How to return Http Status Code from ASP.NET Web API Controller ?
There are times when you might want to return the Http Status code from an action method of a ASP.NET Web Api Controller. One of the simplest way of doing this is using the CreateResponse method of the HttpRequestMessage as shown below. The sample below demonstrates how to return the status code 304 and 200 based on the last modified date of the employee record….
How to Redirect To Action between Areas in ASP.NET MVC?
There are times when you want to redirect to a specific area from different area. In this, one can use the RedirectToAction method to achieve it and pass the parameter area. How to Redirect between Areas in ASP.NET MVC?
How to read connection string from web.config in ASP.NET and C# ?
Here’s a sample code snippet demonstrating how to get the connection string from your ASP.NET web.config file so that you can make a connection to the database. How to read connection string from web.config in ASP.NET and C# ? Assume that the connection string name defined in the web.config file is “conn1” , you would get the connection string using the ConnectionManager class.