Technical interview Q&A plus 100+ career & HR questions—notice period, salary negotiation, resume, LinkedIn, freelancing, AI careers, and behavioral interviews with detailed, real-world answers.
ADO.NET ADO.NET Core Tutorial · ADO.NET
executable code.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
DO.NET (Active Data Objects .NET) is a data access technology in the .NET framework
that enables applications to interact with databases and other data sources. It provides a set
of classes for connecting to databases, retrieving data, manipulating data, and updating
data. ADO.NET is designed for disconnected data access, meaning that data can be
retrieved, modified, and worked with without maintaining an ongoing connection to the
database.
Real-Time Example:
In a C# application, ADO.NET is used to retrieve a list of products from a database and
display it in a UI like a GridView. The data is fetched from the database, stored in a DataSet
or DataTable, and then bound to the UI controls.
ADO.NET ADO.NET Core Tutorial · ADO.NET
DataReader).
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: memory-efficient and fast for large result sets. It reads data row-by-row instead of loading everything into memory at once, like a DataSet.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Flyweight Pattern reduces memory consumption significantly. Instead of
creating multiple objects for each appearance of a character, only one object
is created for each unique character.
ADO.NET ADO.NET Core Tutorial · ADO.NET
hasn't been committed yet. Fast but can result in inconsistencies.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
users to read and modify data without locking it.
user fetched earlier (usually by checking a timestamp or version number). If the data
has been changed by someone else, you throw a concurrency exception.
Steps:
Example:
SqlCommand command = new SqlCommand("UPDATE Customers SET
CustomerName = @CustomerName WHERE CustomerID = @CustomerID AND
RowVersion = @RowVersion", connection);
command.Parameters.AddWithValue("@CustomerName", customerName);
command.Parameters.AddWithValue("@CustomerID", customerId);
command.Parameters.AddWithValue("@RowVersion", rowVersion);
If the RowVersion has changed between the time the user fetched the data and the time
they attempt to update, the update will fail, and an exception will be thrown.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: command or stored procedure. Example: SqlCommand command = new SqlCommand("SELECT * FROM Customers", connection);
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
empty, check for valid formats, or check for duplicate records).
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
DataTable.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
CommandType.StoredProcedure.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
SqlCommand command = new SqlCommand("SELECT CustomerName,
ContactName FROM Customers WHERE CustomerID = @CustomerID",
connection);
command.Parameters.AddWithValue("@CustomerID", 1);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
if (reader.Read()) // Checks if there's data
{
string customerName = reader["CustomerName"].ToString();
string contactName = reader["ContactName"].ToString();
Console.WriteLine($"Customer: {customerName}, Contact:
{contactName}");
}
reader.Close();
connection.Close();
ADO.NET ADO.NET Core Tutorial · ADO.NET
pages) using SQL's LIMIT, OFFSET, or TOP clauses. You can implement paging on
both the server side (in the SQL query) and the client side (in the ASP.NET
application).
Example (Using Paging in SQL):
string query = "SELECT * FROM Customers ORDER BY CustomerID OFFSET
@Offset ROWS FETCH NEXT @PageSize ROWS ONLY";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@Offset", pageNumber * pageSize);
command.Parameters.AddWithValue("@PageSize", pageSize);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
// Process data
Follow:
reader.Close();
connection.Close();
ADO.NET ADO.NET Core Tutorial · ADO.NET
case, a CustomerID). Practical/Scenario-Based ADO.NET Questions
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Example of preventing SQL injection: SqlCommand command = new SqlCommand("SELECT * FROM Customers WHERE CustomerName = @CustomerName", connection); command.Parameters.AddWithValue("@CustomerName", customerName); // Use parameterized query
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: UpdateCommand, and DeleteCommand properties of the DataAdapter to define how data changes should be applied to the database.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: ccess, Oracle). Example: OleDbCommand command = new OleDbCommand("SELECT * FROM Customers", connection);
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Pessimistic Concurrency locks the data when it is being read or modified to ensure that no other transaction can access it until the current operation is complete. This is usually done with SQL transactions and locking hints.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Example:
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
SqlConnection connection = new
SqlConnection(connectionString);
SqlDataAdapter adapter = new SqlDataAdapter("SELECT
CustomerID, CustomerName FROM Customers", connection);
DataTable dataTable = new DataTable();
Follow:
adapter.Fill(dataTable);
GridView1.DataSource = dataTable;
GridView1.DataBind();
Here, GridView1 is bound to the data returned from the SQL query (SELECT
CustomerID, CustomerName FROM Customers), and the DataBind() method
displays it in the grid.
ADO.NET ADO.NET Core Tutorial · ADO.NET
The main components of ADO.NET are:
data source.
database.
DataTables and relationships.
DataSet or updates a data source.
ADO.NET ADO.NET Core Tutorial · ADO.NET
dapter.Fill(dataTable);
GridView1.DataSource = dataTable;
GridView1.DataBind();
}
}
Here, GridView1 is bound to the data returned from the SQL query (SELECT
CustomerID, CustomerName FROM Customers), and the DataBind() method
displays it in the grid.
ADO.NET ADO.NET Core Tutorial · ADO.NET
manner, one row at a time, without creating copies of the data.
relationships) and populate in memory.
ADO.NET ADO.NET Core Tutorial · ADO.NET
pplication).
Example (Using Paging in SQL):
string query = "SELECT * FROM Customers ORDER BY CustomerID OFFSET
@Offset ROWS FETCH NEXT @PageSize ROWS ONLY";
SqlCommand command = new SqlCommand(query, connection);
command.Parameters.AddWithValue("@Offset", pageNumber * pageSize);
command.Parameters.AddWithValue("@PageSize", pageSize);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
// Process data
}
reader.Close();
connection.Close();
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: dapter.Fill(dataset, "Customers"); // Modify data in the DataSet dataset.Tables["Customers"].Rows[0]["CustomerName"] = "New Name"; // Update the database with the modified data dapter.Update(dataset, "Customers");
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
the data in a DataReader.
Example:
string query = "SELECT Customers.CustomerID, Customers.CustomerName,
Orders.OrderID, Orders.OrderDate " +
"FROM Customers " +
"INNER JOIN Orders ON Customers.CustomerID =
Orders.CustomerID";
SqlCommand command = new SqlCommand(query, connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
Follow:
Console.WriteLine("Customer: " + reader["CustomerName"] + ",
Order ID: " + reader["OrderID"]);
reader.Close();
connection.Close();
Alternatively, you can use a DataSet to load data from multiple tables, which will maintain
the relationships between the tables.
Example (Using DataSet):
string query = "SELECT * FROM Customers; SELECT * FROM Orders";
SqlDataAdapter adapter = new SqlDataAdapter(query, connection);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
Here, dataSet.Tables[0] will contain Customers, and dataSet.Tables[1] will
contain Orders.
ADO.NET ADO.NET Core Tutorial · ADO.NET
databases in a connected environment (requiring an open connection to the
database for the duration of data retrieval).
you to retrieve data, work on it offline (disconnected), and then send any changes
back to the database.
Key Differences:
disconnected model (DataSet, DataTable).
applications.
Follow:
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: database operations asynchronously to avoid blocking the main thread and keep the application responsive.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Example: using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); // Execute commands here connection.Close(); }
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Example: SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Customers", connection); DataTable dt = new DataTable(); Follow: adapter.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind();
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Example:
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlTransaction transaction = connection.BeginTransaction();
try
{
SqlCommand command1 = new SqlCommand("UPDATE Customers SET
Balance = Balance - 100", connection, transaction);
SqlCommand command2 = new SqlCommand("UPDATE Accounts SET
Balance = Balance + 100", connection, transaction);
command1.ExecuteNonQuery();
command2.ExecuteNonQuery();
transaction.Commit(); // Commit the transaction
}
catch (Exception)
{
transaction.Rollback(); // Rollback if there is an error
}
finally
{
connection.Close();
}ADO.NET ADO.NET Core Tutorial · ADO.NET
Example:
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM
Customers", connection);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(adapter);
// Automatically generates insert, update, delete commands
Follow:
DataSet dataset = new DataSet();
adapter.Fill(dataset, "Customers");
// Modify data in the DataSet
dataset.Tables["Customers"].Rows[0]["CustomerName"] = "New Name";
// Update the database with the modified data
adapter.Update(dataset, "Customers");
ADO.NET ADO.NET Core Tutorial · ADO.NET
Example:
// Assuming you already have a populated DataTable
DataTable table = new DataTable();
Follow:
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM
Customers", connection);
// Set commands for Insert, Update, and Delete
adapter.UpdateCommand = new SqlCommand("UPDATE Customers SET
CustomerName = @CustomerName WHERE CustomerID = @CustomerID",
connection);
adapter.UpdateCommand.Parameters.Add("@CustomerName",
SqlDbType.NVarChar, 100, "CustomerName");
adapter.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.Int,
4, "CustomerID");
// Update the database
adapter.Update(table);
After modifying the DataTable, the Update method pushes those changes to the database.
ADO.NET ADO.NET Core Tutorial · ADO.NET
dapter.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind();
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: dapter.Fill(dataset, "Customers"); // Populates the DataSet with data from the "Customers" table
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
dapter.UpdateCommand = new SqlCommand("UPDATE Customers SET
CustomerName = @CustomerName WHERE CustomerID = @CustomerID",
connection);
dapter.UpdateCommand.Parameters.Add("@CustomerName",
SqlDbType.NVarChar, 100, "CustomerName");
dapter.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.Int,
4, "CustomerID");
// Update the database
dapter.Update(table);
fter modifying the DataTable, the Update method pushes those changes to the database.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Example: SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Customers", connection); DataSet dataset = new DataSet(); adapter.Fill(dataset, "Customers"); // Populates the DataSet with data from the "Customers" table
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
dates).
Example:
string customerName = txtCustomerName.Text;
if (string.IsNullOrWhiteSpace(customerName))
{
throw new ArgumentException("Customer name cannot be empty");
}
SqlCommand command = new SqlCommand("INSERT INTO Customers
(CustomerName) VALUES (@CustomerName)", connection);
command.Parameters.AddWithValue("@CustomerName", customerName);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
This ensures that the CustomerName is not empty before inserting it into the database.
ADO.NET ADO.NET Core Tutorial · ADO.NET
ExecuteScalar() depending on the type of result.
Example:
SqlCommand command = new SqlCommand("GetCustomerDetails",
connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@CustomerID", customerId);
SqlDataReader reader = command.ExecuteReader();ADO.NET ADO.NET Core Tutorial · ADO.NET
possible.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Connectivity) drivers. Example: OdbcCommand command = new OdbcCommand("SELECT * FROM Customers", connection);
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
don’t need to modify the data or navigate backward.
offline, and later update the database.
Example (using DataReader for better performance):
SqlCommand command = new SqlCommand("SELECT * FROM Customers",
connection);
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader["CustomerName"].ToString());
}
reader.Close();
When to Use:
without requiring complex data manipulation.
modify data offline.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: restrictive but guarantees the highest level of consistency. You set the isolation level using the Transaction object: SqlTransaction transaction = connection.BeginTransaction(IsolationLevel.Serializable);
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Example: OracleCommand command = new OracleCommand("SELECT * FROM Customers", connection);
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
disconnected mode. A DataSet can hold multiple DataTables, each corresponding to
a database table or view. It's also capable of handling data relationships, such as
parent-child relationships.
their orders.
one database table and allows you to work with the data offline.
representing each customer.
ADO.NET ADO.NET Core Tutorial · ADO.NET
database table or view. It's also capable of handling data relationships, such as
parent-child relationships.
their orders.
one database table and allows you to work with the data offline.
representing each customer.
ADO.NET ADO.NET Core Tutorial · ADO.NET
It can also be updated and later written back to the database. You can move back
and forth between rows (using DataRow and DataColumn).
faster, streaming access to the data from the database but doesn’t allow
modifications. It maintains an open connection while reading data.
Example:
Orders, and Products, you'd use a DataSet.
DataReader would be used.
ADO.NET ADO.NET Core Tutorial · ADO.NET
nd forth between rows (using DataRow and DataColumn).
faster, streaming access to the data from the database but doesn’t allow
modifications. It maintains an open connection while reading data.
Example:
Orders, and Products, you'd use a DataSet.
DataReader would be used.
ADO.NET ADO.NET Core Tutorial · ADO.NET
DataAdapter serves as a bridge between a DataSet/DataTable and the database. It is
used to fill a DataSet with data and to update changes made in the DataSet back to the
database.
Example:
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM
Customers", connection);
DataSet dataset = new DataSet();
dapter.Fill(dataset, "Customers"); // Fills DataSet with data from
the Customers table
ADO.NET ADO.NET Core Tutorial · ADO.NET
The Connection object represents a connection to a specific data source (e.g., SQL
Server). It is used to establish and manage the connection to the database, execute queries,
and close the connection when done.
Example:
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: nd close the connection when done. Example: SqlConnection connection = new SqlConnection(connectionString); connection.Open();
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
The Command object is used to execute SQL queries or stored procedures against a
database. It encapsulates the SQL statement or stored procedure and returns results.
Example:
SqlCommand command = new SqlCommand("SELECT * FROM Customers",
connection);
SqlDataReader reader = command.ExecuteReader();ADO.NET ADO.NET Core Tutorial · ADO.NET
Follow:
UPDATE, DELETE).
It returns a DataReader.
cell of data).
aggregate values).
ADO.NET ADO.NET Core Tutorial · ADO.NET
The ConnectionString contains information required to connect to the database, such as
the database server, database name, credentials, and other configurations.
Example:
string connectionString = "Data Source=server_name;Initial
Catalog=database_name;User ID=user_name;Password=password;";ADO.NET ADO.NET Core Tutorial · ADO.NET
data sources, such as MS Access, Excel, Oracle, etc.
Example:
Use SqlConnection for SQL Server:
SqlConnection sqlConnection = new SqlConnection(connectionString);
OleDbConnection oleDbConnection = new
OleDbConnection(connectionString);
ADO.NET ADO.NET Core Tutorial · ADO.NET
etc.) that is executed directly against the database.
executed as a unit. It can contain more complex logic, including control-of-flow and
error handling.
Example:
ADO.NET ADO.NET Core Tutorial · ADO.NET
Connection Pooling allows multiple applications or threads to reuse existing database
connections instead of opening a new connection each time. It improves performance by
reducing the overhead of opening and closing connections repeatedly.
Example: When using SQL Server, the connection pool automatically manages the reuse of
connections.
ADO.NET ADO.NET Core Tutorial · ADO.NET
which allows applications to work offline, reducing the load on the database.
large data volumes efficiently.
XML data.
ADO.NET ADO.NET Core Tutorial · ADO.NET
examples.
You can navigate and manipulate the data offline.
processing.
the database. It is faster for reading large amounts of data in a streaming manner.
in a single-pass, forward-only manner.
ADO.NET ADO.NET Core Tutorial · ADO.NET
The CommandTimeout property specifies the amount of time (in seconds) before a
command is considered to have timed out. If the command execution takes longer than the
specified time, an error is raised.
Example:
SqlCommand command = new SqlCommand("SELECT * FROM Customers",
connection);
command.CommandTimeout = 30; // Timeout after 30 seconds
Intermediate ADO.NET QuestionsADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: The SqlDataAdapter serves as a bridge between a DataSet (or DataTable) and the database. It is responsible for:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
To update the database using a DataSet:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
mount of data quickly and do not need to modify the data. It requires an open connection to
the database and reads data sequentially, one row at a time.
Example:
SqlCommand command = new SqlCommand("SELECT CustomerName FROM
Customers", connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader["CustomerName"]);
}
reader.Close();
ADO.NET ADO.NET Core Tutorial · ADO.NET
The SqlDataReader is used to retrieve data from the database in a forward-only and
read-only manner. It is more efficient than a DataSet when you need to retrieve a large
amount of data quickly and do not need to modify the data. It requires an open connection to
the database and reads data sequentially, one row at a time.
Example:
SqlCommand command = new SqlCommand("SELECT CustomerName FROM
Customers", connection);
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
Console.WriteLine(reader["CustomerName"]);
reader.Close();
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: dapter.Fill(dataset, "Customers"); // Fills the DataSet with data from the "Customers" table
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
The Fill() method of the DataAdapter is used to populate a DataSet or DataTable with data
from the database. It executes the SELECT query defined in the DataAdapter and fills the
specified DataSet or DataTable with the results.
Example:
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM
Customers", connection);
DataSet dataset = new DataSet();
Follow:
adapter.Fill(dataset, "Customers"); // Fills the DataSet with data
from the "Customers" table
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: In ADO.NET, database connections are managed using the Connection object, such as SqlConnection for SQL Server. The process involves:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
To execute a stored procedure using ADO.NET:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
relationships between them. It is used for handling disconnected data and can work
offline, and it can also support complex structures, such as parent-child relationships.
can be used for simpler scenarios where only one table of data is needed.
Example:
ADO.NET ADO.NET Core Tutorial · ADO.NET
To bind a DataTable to a GridView in ASP.NET:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
DO.NET exceptions are typically handled using try-catch blocks. This helps to capture any
errors during database operations such as connection failures, query issues, or command
execution errors.
Example:
try
{
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlCommand command = new SqlCommand("SELECT * FROM Customers",
connection);
SqlDataReader reader = command.ExecuteReader();
}
catch (SqlException ex)
{
Console.WriteLine("Database error: " + ex.Message);
}
catch (Exception ex)
{
Console.WriteLine("General error: " + ex.Message);
}ADO.NET ADO.NET Core Tutorial · ADO.NET
The SqlConnection object is responsible for opening a connection to a SQL Server
database. It represents the physical connection to the data source and must be open before
executing commands (like SqlCommand) or reading data (using SqlDataReader or
SqlDataAdapter).
Example:
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
// Execute database commands
connection.Close();
ADO.NET ADO.NET Core Tutorial · ADO.NET
Definition) file, which defines the structure of the data (tables, columns,
relationships). It provides type safety and compile-time checking.
meaning you access tables and columns by name at runtime. This offers flexibility but
no compile-time checking.
Example:
intellisense.ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: transaction in ADO.NET is a sequence of database operations that are executed as a single unit. If one operation fails, all previous operations are rolled back. You can manage transactions using the SqlTransaction object. Steps:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
You can execute multiple transactions sequentially by managing multiple SqlTransaction
objects. Each transaction can either be committed or rolled back based on the success or
failure of the operations.
Example:
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlTransaction transaction1 = connection.BeginTransaction();
SqlTransaction transaction2 = connection.BeginTransaction();
Follow:
try
// First transaction
SqlCommand command1 = new SqlCommand("UPDATE Customers SET
Balance = Balance - 100", connection, transaction1);
command1.ExecuteNonQuery();
transaction1.Commit();
Advanced ADO.NET Questions
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: In ADO.NET, the Command object is used to execute SQL queries or stored procedures. The main types of Command objects are:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
ADO.NET supports asynchronous database operations using the async and await
keywords in C#. This allows the application to remain responsive while waiting for the
database operation to complete.
asynchronously.
Example:
public async Task GetDataAsync()
SqlConnection connection = new SqlConnection(connectionString);
await connection.OpenAsync();
SqlCommand command = new SqlCommand("SELECT * FROM Customers",
connection);
SqlDataReader reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
Console.WriteLine(reader["CustomerName"].ToString());
reader.Close();
Follow:
ADO.NET ADO.NET Core Tutorial · ADO.NET
DO.NET?
DO.NET supports asynchronous database operations using the async and await
keywords in C#. This allows the application to remain responsive while waiting for the
database operation to complete.
synchronously.
Example:
public async Task GetDataAsync()
{
SqlConnection connection = new SqlConnection(connectionString);
wait connection.OpenAsync();
SqlCommand command = new SqlCommand("SELECT * FROM Customers",
connection);
SqlDataReader reader = await command.ExecuteReaderAsync();
while (await reader.ReadAsync())
{
Console.WriteLine(reader["CustomerName"].ToString());
}
reader.Close();
}ADO.NET ADO.NET Core Tutorial · ADO.NET
DO.NET.
stored procedure is a precompiled set of SQL statements that are stored and executed
on the database server. They can improve performance and security by encapsulating
complex operations.
In ADO.NET, stored procedures are executed using the SqlCommand object, where the
CommandType property is set to CommandType.StoredProcedure.
Example:
SqlCommand command = new SqlCommand("GetCustomerDetails",
connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@CustomerID", customerId);
SqlDataReader reader = command.ExecuteReader();ADO.NET ADO.NET Core Tutorial · ADO.NET
Parameters are used to pass values to SQL commands or stored procedures. They provide
a way to safely and securely inject data into queries, reducing the risk of SQL injection
attacks.
In ADO.NET, you handle parameters using the Parameters collection of a SqlCommand
object.
Example:
SqlCommand command = new SqlCommand("SELECT * FROM Customers WHERE
CustomerID = @CustomerID", connection);
command.Parameters.AddWithValue("@CustomerID", customerId);
ADO.NET ADO.NET Core Tutorial · ADO.NET
way to safely and securely inject data into queries, reducing the risk of SQL injection
ttacks.
In ADO.NET, you handle parameters using the Parameters collection of a SqlCommand
object.
Example:
SqlCommand command = new SqlCommand("SELECT * FROM Customers WHERE
CustomerID = @CustomerID", connection);
command.Parameters.AddWithValue("@CustomerID", customerId);
ADO.NET ADO.NET Core Tutorial · ADO.NET
SQL injection attacks can be prevented by:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: snapshot of the data and remains unchanged even if the data in the database changes during the operation. It is slower and consumes more memory compared to forward-only cursor.
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
direction only. It is fast and lightweight, but you cannot go back to previous rows.
a snapshot of the data and remains unchanged even if the data in the database
changes during the operation. It is slower and consumes more memory compared to
a forward-only cursor.
ADO.NET ADO.NET Core Tutorial · ADO.NET
n ADO.NET DataProvider is a set of classes used to interact with different types of data
sources (such as SQL Server, Oracle, etc.). It provides methods for opening connections,
executing commands, and retrieving data.
The main types of DataProviders are:
ADO.NET ADO.NET Core Tutorial · ADO.NET
llows you to define the name, data type, size, and value of a parameter. SqlParameter is
used to protect against SQL injection and to pass data to SQL queries safely.
Example:
SqlCommand command = new SqlCommand("SELECT * FROM Customers WHERE
CustomerID = @CustomerID", connection);
SqlParameter parameter = new SqlParameter("@CustomerID",
SqlDbType.Int);
parameter.Value = customerId;
command.Parameters.Add(parameter);
ADO.NET ADO.NET Core Tutorial · ADO.NET
The SqlParameter class represents a parameter to a SQL command or stored procedure. It
allows you to define the name, data type, size, and value of a parameter. SqlParameter is
used to protect against SQL injection and to pass data to SQL queries safely.
Example:
SqlCommand command = new SqlCommand("SELECT * FROM Customers WHERE
CustomerID = @CustomerID", connection);
SqlParameter parameter = new SqlParameter("@CustomerID",
SqlDbType.Int);
parameter.Value = customerId;
command.Parameters.Add(parameter);
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Isolation levels define the level of visibility one transaction has into the changes made by other concurrent transactions. The four isolation levels in ADO.NET are:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Batch processing allows you to execute multiple SQL commands in a single round trip to the
database, which can improve performance when you have a large number of operations to
perform.
You can use the SqlCommand object to execute a batch of SQL statements separated by
semicolons.
Example:
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = "INSERT INTO Customers (Name) VALUES ('John');
INSERT INTO Orders (OrderDate) VALUES ('2025-01-01');";
command.ExecuteNonQuery();
ADO.NET ADO.NET Core Tutorial · ADO.NET
cross multiple data sources (e.g., SQL Server and other databases). It simplifies
transaction management by automatically handling the commit and rollback of transactions
cross multiple resources.
Example:
using (TransactionScope scope = new TransactionScope())
{
SqlConnection connection1 = new
SqlConnection(connectionString1);
SqlConnection connection2 = new
SqlConnection(connectionString2);
connection1.Open();
connection2.Open();
// Execute commands on both connections
scope.Complete(); // Commit the transaction if everything is
successful
}ADO.NET ADO.NET Core Tutorial · ADO.NET
The TransactionScope class in ADO.NET is used to handle distributed transactions
across multiple data sources (e.g., SQL Server and other databases). It simplifies
transaction management by automatically handling the commit and rollback of transactions
across multiple resources.
Example:
using (TransactionScope scope = new TransactionScope())
SqlConnection connection1 = new
SqlConnection(connectionString1);
SqlConnection connection2 = new
SqlConnection(connectionString2);
connection1.Open();
connection2.Open();
// Execute commands on both connections
scope.Complete(); // Commit the transaction if everything is
successful
Follow:
ADO.NET ADO.NET Core Tutorial · ADO.NET
The UpdateCommand property of the DataAdapter specifies the SQL command used to
update the database when changes are made to the data in the DataSet. The Update()
method of the DataAdapter uses the UpdateCommand to push changes back to the
database.
Example:
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM
Customers", connection);
adapter.UpdateCommand = new SqlCommand("UPDATE Customers SET Name =
@Name WHERE CustomerID = @CustomerID", connection);
adapter.UpdateCommand.Parameters.Add("@Name", SqlDbType.NVarChar,
100, "Name");
adapter.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.Int,
4, "CustomerID");
ADO.NET ADO.NET Core Tutorial · ADO.NET
dapter.UpdateCommand = new SqlCommand("UPDATE Customers SET Name =
@Name WHERE CustomerID = @CustomerID", connection);
dapter.UpdateCommand.Parameters.Add("@Name", SqlDbType.NVarChar,
100, "Name");
dapter.UpdateCommand.Parameters.Add("@CustomerID", SqlDbType.Int,
4, "CustomerID");
ADO.NET ADO.NET Core Tutorial · ADO.NET
concurrency in ADO.NET.
users to read and modify the data without locking the record. However, when
updating, it checks if the data has been modified by another user since it was last
read.
preventing other users from accessing it until the transaction is complete. It can
reduce conflicts but may result in performance issues.
ADO.NET ADO.NET Core Tutorial · ADO.NET
DataSet or DataTable, and update the UI when the data changes. Examples include
GridView, DropDownList, and ListBox.
data changes. You need to manually manage data binding, such as updating the
display values when the data changes.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Performance can be optimized by:
database connections.
ADO.NET ADO.NET Core Tutorial · ADO.NET
can lead to high memory usage, especially with large datasets.
slower compared to DataReader for large result sets or when working with large
amounts of data.
ADO.NET ADO.NET Core Tutorial · ADO.NET
The DataReader is more efficient than DataSet when dealing with large result sets because
it reads data in a forward-only, read-only manner, without storing the entire result set in
memory. This results in better performance and lower memory consumption.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Paging is implemented by retrieving a subset of data, typically using SQL's LIMIT (MySQL),
TOP (SQL Server), or ROWNUM (Oracle) to limit the number of rows returned.
Example (SQL Server):
SqlCommand command = new SqlCommand("SELECT * FROM Customers ORDER
BY CustomerID OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY", connection);
SqlDataReader reader = command.ExecuteReader();ADO.NET ADO.NET Core Tutorial · ADO.NET
Stored procedure parameters are handled by adding SqlParameter objects to the
SqlCommand's Parameters collection. You set the parameter name, data type, and value.
Example:
SqlCommand command = new SqlCommand("GetCustomerDetails",
connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@CustomerID", customerId);
ADO.NET ADO.NET Core Tutorial · ADO.NET
DataRelation defines a relationship between two DataTable objects in a DataSet. It is
used to enforce referential integrity and allows for navigating between related data in a
parent-child relationship.
Example:
DataRelation relation = new DataRelation("ParentChild",
parentTable.Columns["ID"], childTable.Columns["ParentID"]);
dataSet.Relations.Add(relation);
ADO.NET ADO.NET Core Tutorial · ADO.NET
DO.NET supports several types of locks during transactions:
locked data.
exclusive lock.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Connection Pooling is a technique used to optimize the performance of database
connections in ADO.NET. When an application opens a connection to a database, the
connection is not always closed immediately. Instead, it is placed in a connection pool for
reuse by future requests. This avoids the overhead of repeatedly opening and closing
connections to the database.
Key Points:
the pool, making it available for reuse.
need to handle the pool directly.
When a connection is needed, one is retrieved from the pool; when it is no longer
needed, it is returned to the pool.
Benefits:
Example:
// The connection string should have pooling enabled by default
string connectionString =
"Server=myServerAddress;Database=myDataBase;Integrated
Security=True;Pooling=True;Max Pool Size=100;";
// Use SqlConnection as usual
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
The Pooling=True in the connection string ensures that the connections are pooled.
ADO.NET ADO.NET Core Tutorial · ADO.NET
The ExecuteScalar method in ADO.NET is used to execute a query that returns a single
value, typically an aggregate value like a count, sum, or average, or a single field from a row.
This method is ideal when you expect a single value as the result, rather than a set of rows.
Key Points:
rows are ignored.
MIN()).
Example:
SqlCommand command = new SqlCommand("SELECT COUNT(*) FROM
Customers", connection);
connection.Open();
int customerCount = (int)command.ExecuteScalar();
Console.WriteLine("Number of customers: " + customerCount);
In this example, ExecuteScalar returns the number of rows in the Customers table.
ADO.NET ADO.NET Core Tutorial · ADO.NET
nd columns, and it is used to hold data returned from the database.
Key Features:
rows).
Example:
DataTable table = new DataTable();
table.Columns.Add("ID");
table.Columns.Add("Name");
table.Rows.Add(1, "Alice");
table.Rows.Add(2, "Bob");
the underlying data. It allows you to sort and filter the data dynamically.
Key Features:
Example:
DataView view = new DataView(table);
view.RowFilter = "Name = 'Alice'";
view.Sort = "ID DESC";
the DataTable.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Both DataTable and DataView are used to represent data in ADO.NET, but they have
different purposes:
and columns, and it is used to hold data returned from the database.
Key Features:
Follow:
rows).
Example:
DataTable table = new DataTable();
table.Columns.Add("ID");
table.Columns.Add("Name");
table.Rows.Add(1, "Alice");
table.Rows.Add(2, "Bob");
the underlying data. It allows you to sort and filter the data dynamically.
Key Features:
Example:
DataView view = new DataView(table);
view.RowFilter = "Name = 'Alice'";
view.Sort = "ID DESC";
Summary:
the DataTable.
Follow:
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: DataReader offers significant performance advantages over DataSet in specific scenarios, especially when you are working with large volumes of data:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
DO.NET?
To retrieve a single row or column of data, you can use a SqlCommand and either execute
it with ExecuteScalar (for single column data) or ExecuteReader (for a single row).
Using ExecuteScalar (for a single column value, like an aggregate):
SqlCommand command = new SqlCommand("SELECT CustomerName FROM
Customers WHERE CustomerID = @CustomerID", connection);
command.Parameters.AddWithValue("@CustomerID", 1);
connection.Open();
string customerName = (string)command.ExecuteScalar();
Console.WriteLine("Customer Name: " + customerName);
connection.Close();
ADO.NET ADO.NET Core Tutorial · ADO.NET
To retrieve a single row or column of data, you can use a SqlCommand and either execute
it with ExecuteScalar (for single column data) or ExecuteReader (for a single row).
Using ExecuteScalar (for a single column value, like an aggregate):
SqlCommand command = new SqlCommand("SELECT CustomerName FROM
Customers WHERE CustomerID = @CustomerID", connection);
command.Parameters.AddWithValue("@CustomerID", 1);
connection.Open();
string customerName = (string)command.ExecuteScalar();
Console.WriteLine("Customer Name: " + customerName);
connection.Close();
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: You can fetch data from multiple tables in ADO.NET using various SQL techniques, such as JOINs (e.g., INNER JOIN, LEFT JOIN) or subqueries. Steps:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: nd sync with the database? To update multiple records in a DataTable and sync the changes with the database, you need to follow these steps:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: To update multiple records in a DataTable and sync the changes with the database, you need to follow these steps:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: In an ASP.NET WebForms application, you can use the GridView control to display data from a database by following these steps:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: When working with large datasets in ADO.NET, it's crucial to ensure that the application does not run into performance issues, such as excessive memory usage or long wait times. Here are some strategies to efficiently retrieve large data:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: Concurrency issues occur when multiple users attempt to update the same data simultaneously. There are two main strategies to handle concurrency in ADO.NET:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Answer: DO.NET? Concurrency issues occur when multiple users attempt to update the same data simultaneously. There are two main strategies to handle concurrency in ADO.NET:
In a production ADO.NET application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ADO.NET ADO.NET Core Tutorial · ADO.NET
Data validation ensures that the data being inserted into the database is correct and
consistent. You can perform validation at various stages, including the client side (e.g.,
using JavaScript in a web application) and server side (using ADO.NET).
Steps for Server-Side Validation:
ADO.NET ADO.NET Core Tutorial · ADO.NET
The BatchUpdate method is used to send multiple SQL commands (such as insert, update,
or delete) in a single round trip to the database. This improves performance by reducing the
overhead of sending multiple individual commands.
While BatchUpdate isn't directly exposed as a method on the DataAdapter object, you
can achieve similar functionality by manually creating a batch of commands and executing
them in a single call.
Example (Using SqlDataAdapter):
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM
Customers", connection);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter); //
Automatically generates commands for Update, Insert, and Delete
DataTable table = new DataTable();
adapter.Fill(table);
// Modify DataTable as needed
// Update changes to the database in one go (BatchUpdate)
adapter.Update(table);
Follow:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Filters are ASP.NET Core’s plug-in points that allow you to inject logic before or after
specific pipeline stages such as:
They help you implement cross-cutting concerns without cluttering controllers or actions.
In enterprise systems, filters are indispensable for:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: filter is a component that allows logic to be executed before or after parts of the request pipeline, such as authorization, action execution, or result processing.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Middleware is a component in the HTTP request pipeline that can:
Middleware can:
Middleware executes in the order it's added in Program.cs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
uthorization checks directly inside controllers. This led to:
Filters solve these by offering centralized, consistent, and reusable implementation points.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
pp.UseMiddleware<YourMiddleware>();
pp.UseRouting();
pp.UseEndpoints(endpoints => { endpoints.MapControllers();
});
pp.Run();
public void Configure(IApplicationBuilder app,
IWebHostEnvironment env)
{
pp.UseMiddleware<YourMiddleware>();
pp.UseRouting();
pp.UseEndpoints(endpoints => {
endpoints.MapControllers(); });
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
uthorization, Resource, Action, Exception, and Result filters.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Program.cs:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseMiddleware<YourMiddleware>();
app.UseRouting();
app.UseEndpoints(endpoints => { endpoints.MapControllers();
});
app.Run();
public void Configure(IApplicationBuilder app,
IWebHostEnvironment env)
app.UseMiddleware<YourMiddleware>();
app.UseRouting();
app.UseEndpoints(endpoints => {
endpoints.MapControllers(); });
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
uthorization Before everything Identity, JWT, RBAC
Resource Before model binding Caching, request trimming
ction Before/after action Logging, validation
Exception On unhandled errors Global error handling
Result Before/after result Response wrapping,
formatting
Endpoint (ASP.NET Core
7+)
round minimal API
endpoints
Logging, validation
3.1 Authorization Filters
These execute first, determining whether the user can access the route.
Typical use cases:
3.2 Resource Filters
Executed before model binding.
Perfect for:
3.3 Action Filters
The most commonly used filter type.
Great for:
Example – Audit Logging Filter
public class AuditLogFilter : IActionFilter
{
private readonly ILogger<AuditLogFilter> _logger;
public AuditLogFilter(ILogger<AuditLogFilter> logger)
{
_logger = logger;
}
public void OnActionExecuting(ActionExecutingContext context)
{
_logger.LogInformation("Request started at: {time}",
DateTime.UtcNow);
}
public void OnActionExecuted(ActionExecutedContext context)
{
_logger.LogInformation("Request ended at: {time}",
DateTime.UtcNow);
}
}
3.4 Exception Filters
Centralizing error handling is vital in fintech and healthcare APIs.
Example use cases:
3.5 Result Filters
These wrap the response.
Use cases:
3.6 Endpoint Filters (ASP.NET Core 7+)
Primarily for minimal APIs.
Example use cases:
pp.MapGet("/users/{id}", (int id) => GetUser(id))
.AddEndpointFilter(new LoggingEndpointFilter());
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Example – Using ServiceFilter [ServiceFilter(typeof(AuditLogFilter))] public class UserController : ControllerBase { }
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Authorization Filters Resource Filters Action Filters Exception Filters Result Filters Endpoint Filters (ASP.NET Core 7+)
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Filters promote reusability, separation of concerns, cleaner controllers, and easier maintenance.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
pp.Map
Method Description
pp.Use Adds middleware that can call next in the
pipeline.
pp.UseMiddlewar
e<T>()
dds a custom middleware class.
pp.Run Terminal middleware – does not call next. Ends
the pipeline.
pp.Map Branches the pipeline based on URL path (e.g.
/api).
Example:
pp.Use(async (context, next) => {
wait next(); // go to next middleware
});
pp.Run(async context => {
wait context.Response.WriteAsync("Hello World"); //
terminates pipeline
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Create a class with:
public class MyCustomMiddleware
private readonly RequestDelegate _next;
public MyCustomMiddleware(RequestDelegate next) => _next =
next;
public async Task InvokeAsync(HttpContext context)
// Pre-processing logic
await _next(context);
// Post-processing logic
Register it:
app.UseMiddleware<MyCustomMiddleware>();
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Diagram)
| Authorization Filter |
| Resource Filter |
| Model Binding Happens |
| Action Filter |
| Action Method |
| Result Filter |
| Response Returned |
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: wait _next(context); // Post-processing logic } } Register it: pp.UseMiddleware<MyCustomMiddleware>();
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: ction filters wrap the action method; result filters wrap the returned result (like ObjectResult or ViewResult).
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Filters can be created using:
Example – Custom Header Validation Filter
public class HeaderValidationFilter : IActionFilter
{
public void OnActionExecuting(ActionExecutingContext context)
{
if
(!context.HttpContext.Request.Headers.ContainsKey("X-Client-Id"))
{
context.Result = new BadRequestObjectResult("Missing
X-Client-Id header.");
}
}
public void OnActionExecuted(ActionExecutedContext context) { }
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
uthorization filters always run first. Intermediate Level
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: RequestDelegate is a delegate representing the next middleware in the pipeline: public delegate Task RequestDelegate(HttpContext context); In custom middleware, it allows passing control to the next component.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pp.UseAuthentication(); // Must come before authorization pp.UseAuthorization(); pp.UseEndpoints(...); Logging, error handling, and security middlewares must be early in the pipeline.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Middleware is executed in the order it's added, and this order affects
behavior.
Example:
app.UseAuthentication(); // Must come before authorization
app.UseAuthorization();
app.UseEndpoints(...);
Logging, error handling, and security middlewares must be early
in the pipeline.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: They run before model binding and after authorization. Perfect for caching or request trimming.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
✔ Use Filters When:
❌ Avoid Filters If:
⚠ Pitfall: Filters run per action. Be mindful of expensive operations.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Simply don’t call await next() in a middleware: if (!context.User.Identity.IsAuthenticated) context.Response.StatusCode = 401; return; // Short-circuits await next(); // only called if authenticated
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Set context.Result = new BadRequestObjectResult(...).
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
wait next(); // only called if authenticated
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Concern Use Filter Use Middleware
Needs controller context ✔ ❌
Needs access before
routing
❌ ✔
Validating request body ❌ ✔
Logging per action ✔ ❌
Exception handling ✔ ✔
💡 Tip: If your logic is unrelated to MVC actions (e.g., CORS, compression),
middleware is the right choice.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pp.UseStaticFiles() enables serving files from wwwroot. Important: It must be added before routing or endpoints so static files re served without invoking controller logic. pp.UseStaticFiles(); pp.UseRouting(); pp.UseEndpoints(...);
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Yes—via constructor injection, ServiceFilter, or TypeFilter.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
SP.NET Core filters support DI via:
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: sync filters implement IAsyncActionFilter and support await, improving scalability.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
custom page or handler.
Example:
if (env.IsDevelopment())
pp.UseDeveloperExceptionPage();
else
pp.UseExceptionHandler("/Error");
Or inline:
pp.UseExceptionHandler(errorApp =>
{
errorApp.Run(async context =>
{
context.Response.StatusCode = 500;
wait context.Response.WriteAsync("An error
occurred");
});
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
🏦 Fintech API – Global Exception Filter
Ensures consistent error envelopes across microservices.
🛠 Microservices – Audit Logging
Tracks when sensitive controller actions are executed.
👮 Role-based Authorization
Custom authorization filter validating role claims dynamically.
🚀 Performance Profiling
Times how long each controller method takes.
public class ProfilingFilter : IActionFilter
{
private Stopwatch _watch;
public void OnActionExecuting(ActionExecutingContext context)
{
_watch = Stopwatch.StartNew();
}
public void OnActionExecuted(ActionExecutedContext context)
{
_watch.Stop();
Console.WriteLine($"Action took {_watch.ElapsedMilliseconds}
ms");
}
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
(UseExceptionHandler, UseDeveloperExceptionPage)
only).
a custom page or handler.
Example:
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Error");
Or inline:
app.UseExceptionHandler(errorApp =>
errorApp.Run(async context =>
context.Response.StatusCode = 500;
await context.Response.WriteAsync("An error
occurred");
});
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Redirects HTTP requests to HTTPS. app.UseHttpsRedirection(); Add early in the pipeline, before auth or routing. You can configure HTTPS ports in launchSettings.json or appsettings.json.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Filters execute per controller action → use sparingly. Avoid heavy DB calls. Avoid creating new HttpClients or DbContexts inside filters. Prefer asynchronous filters.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pp.UseHttpsRedirection(); dd early in the pipeline, before auth or routing. You can configure HTTPS ports in launchSettings.json or ppsettings.json.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Yes. They form a pipeline based on their defined order.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
pp.UseStaticFiles(new StaticFileOptions
{
FileProvider = new
PhysicalFileProvider(Path.Combine(env.ContentRootPath,
"MyFiles")),
RequestPath = "/Files",
OnPrepareResponse = ctx =>
{
ctx.Context.Response.Headers.Append("Cache-Control",
"public,max-age=600");
}
});
For directory browsing:
pp.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider("path"),
RequestPath = "/browse"
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use:
var httpContext = new DefaultHttpContext();
var context = new ActionExecutingContext(...);
Focus tests on:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
The sequence in which filters run. Lower Order value = earlier execution.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
middleware
Type Description
Terminal Ends the pipeline. Doesn’t call next(). E.g., app.Run()
Non-Termi
nal
Calls next() and allows other middlewares to run after it.
E.g., app.Use()
Terminal middleware:
app.Run(async ctx => {
await ctx.Response.WriteAsync("This ends the pipeline");
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Mistake Fix
Doing authentication inside action filters Use authorization filters
Performing heavy logic Move to middleware
Not registering filters as services Use DI for maintainability
Returning inconsistent error messages Handle errors via global exception filterASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pp.Run(async ctx => { wait ctx.Response.WriteAsync("This ends the pipeline"); });
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Yes—action filters have full access to ActionArguments.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
pp.UseAuthentication(); // Validates user identity
pp.UseAuthorization(); // Applies policies/roles
Order matters: must be after routing but before endpoints.
pp.UseRouting();
pp.UseAuthentication();
pp.UseAuthorization();
pp.UseEndpoints(...);
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Exception filters only catch exceptions from MVC actions; middleware catches exceptions from the entire pipeline.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: builder.Services.AddCors(options => options.AddPolicy("MyPolicy", policy => policy.WithOrigins(" .AllowAnyHeader() .AllowAnyMethod(); }); }); app.UseCors("MyPolicy"); Must be placed before routing/endpoints.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
pp.UseCors("MyPolicy"); Must be placed before routing/endpoints.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
execution time)
Example custom middleware to measure time:
public class TimingMiddleware
private readonly RequestDelegate _next;
public TimingMiddleware(RequestDelegate next) => _next =
next;
public async Task InvokeAsync(HttpContext context)
var sw = Stopwatch.StartNew();
await _next(context);
sw.Stop();
Console.WriteLine($"Request took
{sw.ElapsedMilliseconds} ms");
Register:
app.UseMiddleware<TimingMiddleware>();
Dependency Injection (DI)
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: wait _next(context); sw.Stop(); Console.WriteLine($"Request took {sw.ElapsedMilliseconds} ms"); } } Register: pp.UseMiddleware<TimingMiddleware>(); Dependency Injection (DI)
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Dependency Injection (DI) is a design pattern that allows you to inject dependencies (services) into classes instead of hard-coding them.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Caching expensive requests where model binding is unnecessary.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
✅ Capabilities:
⚠ Limitations:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Filters specifically built for Minimal APIs (introduced in ASP.NET Core 7).
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Lifetime Description Use Case Example Transient New instance every time Lightweight stateless services Scoped One instance per request Database context, UoW Singleto One instance for the app's lifetime Logging, Config access
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Used for filters that require custom instantiation logic.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Lower order executes first on entry but last on exit—like nested layers.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: public void ConfigureServices(IServiceCollection services) { services.AddTransient<IMyService, MyService>(); services.AddScoped<IRepository, Repository>(); services.AddSingleton<ILoggerService, LoggerService>(); }
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Controllers: Constructor injection Razor Pages: Constructor injection in PageModel Middleware: Inject via constructor or use IApplicationBuilder.ApplicationServices
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use a mocked HttpContext and assert on changes.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Constructor Injection: Supported and preferred in ASP.NET Core. Property Injection: Not supported natively in built-in DI; can be achieved via custom logic or 3rd-party containers. ✅ Use constructor injection for immutability and clarity.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use [SkipFilter] custom attribute or exclude via filter predicates.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
using (var scope = serviceScopeFactory.CreateScope())
{
var scopedService =
scope.ServiceProvider.GetRequiredService<IMyScopedService>();
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
No. But middleware can replace some filter use cases.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Scoped services are tied to the HTTP request lifecycle. In background tasks, you must manually create a scope using IServiceScopeFactory to resolve scoped services safely.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Middleware logs incoming requests; action filter logs controller-level execution.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: To replace: services.AddSingleton<IService, CustomImplementation>(); To remove: var descriptor = services.First(x => x.ServiceType == typeof(IMyService)); services.Remove(descriptor);
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Mixing sync & async can cause deadlocks. Prefer async filters.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
IOptionsMonitor)
services.Configure<MySettings>(Configuration.GetSection("MySettings"
));
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Yes—but avoid heavy operations that run per action.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: there Use IHostedService or BackgroundService for tasks that run in the background. Services are injected via constructor. Scoped services must use IServiceScopeFactory.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use IOptions or DI into constructor.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: IConfiguration is automatically registered and injected via constructor. public MyService(IConfiguration config) { var key = config["MyKey"]; }
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
When exceptions must be caught outside MVC (e.g., authorization failures).
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
SP.NET Core provides structured logging via ILogger<T>.
public class MyService
{
private readonly ILogger<MyService> _logger;
public MyService(ILogger<MyService> logger) => _logger = logger;
public void DoSomething() => _logger.LogInformation("Action
performed");
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
dd custom validation and authorization filters using .AddEndpointFilter().
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Yes—result filters can wrap or modify responses.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Occurs when two services depend on each other directly or indirectly. 🛠 Fix: Refactor to remove circular reference Use Lazy<T> or factory injection Split responsibilities
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
filter that tracks performance of controller actions:
public class ProfilingFilter : IAsyncActionFilter
{
public async Task OnActionExecutionAsync(
ctionExecutingContext context, ActionExecutionDelegate
next)
{
var sw = Stopwatch.StartNew();
var result = await next();
sw.Stop();
Console.WriteLine($"Action took
{sw.ElapsedMilliseconds}ms");
}
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use a mocking framework like Moq:
var mockService = new Mock<IMyService>();
mockService.Setup(s => s.Get()).Returns("test");
var controller = new MyController(mockService.Object);
Mocking helps isolate the unit of work and test behavior independently.
MVC & Razor Pages
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
How does it differ from MVC in
“older” ASP.NET?
🔹 Key differences in ASP.NET Core:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
When to use Razor Pages instead of
MVC?
ASP.NET Core 2.0.
controller combined).
✅ Use Razor Pages for:
✅ Use MVC for:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
SP.NET Core 2.0.
controller combined).
✅ Use Razor Pages for:
✅ Use MVC for:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: }"); Razor Pages Routing: Based on folder structure. URL /Products/Edit maps to /Pages/Products/Edit.cshtml.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Example:
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
/Pages/Products/Edit.cshtml.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: view or JSON). View: .cshtml file that renders HTML. View Component: Reusable mini-views with logic (like partials but with code-behind).
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
a view or JSON).
with code-behind).
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Tag Helpers: Use HTML-like syntax. Easier to read/maintain.
<form asp-controller="Home" asp-action="Login"></form>
@Html.BeginForm("Login", "Home")
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
ta cross requests No Preserved for 1 redirect only
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Purpose ViewDa Current request No Pass data to views ViewBa Current request Yes ViewData wrapper (dynamic) TempD ata Across requests No Preserved for 1 redirect only
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Automatically maps form values, query strings, route data to C# model properties. public IActionResult Submit(User user) { ... } Binds complex types and simple types out-of-the-box.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Decorate model properties: public class User { [Required] [EmailAddress] public string Email { get; set; } } Automatically validated during model binding. Use ModelState.IsValid to check.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: IValidatableObject: public IEnumerable<ValidationResult> Validate(ValidationContext context) Custom Attribute: public class MyCustomAttribute : ValidationAttribute { public override bool IsValid(object value) { ... } }
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
_Layout.cshtml.
public class CartViewComponent : ViewComponent {
public IViewComponentResult Invoke() => View("Cart",
model);
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Via ViewBag / ViewData / Model: return View(model); // Strongly typed ViewBag.Message = "Hello"; ViewData["Count"] = 5;
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: ActionFilter: Runs before/after action method. ResultFilter: Runs before/after view result. ExceptionFilter: Catches unhandled exceptions. Apply globally or via attributes. public class LogActionFilter : IActionFilter { ... }
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Razor Pages use handler methods: public class IndexModel : PageModel { public void OnGet() { ... } public IActionResult OnPost() { ... } } You can use asp-page-handler="Update" for custom methods.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Inject services into PageModel constructor: public IndexModel(IMyService service) { ... } Also available in Razor views via @inject: @inject ILogger<MyPage> Logger
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Reusable libraries that contain Razor views, pages, static files, etc. Share UI components across multiple projects. dotnet new razorclasslib
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Used to organize large applications into sections (e.g., Admin, Customer). Each Area has its own Controllers/Views/Models. [Area("Admin")] public class DashboardController : Controller { ... }
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Handled via: ASP.NET Core Middleware WebOptimizer, Gulp, or Webpack Static files in wwwroot/ Enable in Startup.cs: app.UseStaticFiles();
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: ASP.NET Core supports Razor by default. You can add support for custom view engines by implementing IViewEngine.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Use IStringLocalizer<T> or IViewLocalizer: @inject IViewLocalizer Localizer <h1>@Localizer["Welcome"]</h1> Add resource .resx files for each language.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
large, modular apps.
Web API (RESTful Services)
Web API (RESTful Services)
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
How to design RESTful APIs in ASP.NET Core
REST (Representational State Transfer) is an architectural style for
building scalable web services. RESTful APIs follow standard HTTP
methods (GET, POST, PUT, DELETE) and stateless communication.
✅ Key principles for RESTful API in ASP.NET Core:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
REST (Representational State Transfer) is an architectural style for
building scalable web services. RESTful APIs follow standard HTTP
methods (GET, POST, PUT, DELETE) and stateless communication.
✅ Key principles for RESTful API in ASP.NET Core:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
The [ApiController] attribute is used to denote Web API controllers in
ASP.NET Core.
✅ Benefits:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: SP.NET Core. ✅ Benefits: Automatic model validation Infer [FromBody] / [FromQuery], etc. 400 BadRequest returned automatically if model state is invalid. Improved parameter binding behavior
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
templates)
[Route("api/products")]
[ApiController]
public class ProductsController : ControllerBase {
[HttpGet("{id}")]
public IActionResult Get(int id) { ... }
}
Use placeholders like {id}, constraints like {id:int}.
You can also define route prefixes at controller level and use relative routes
in actions.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
media type versioning)
Use Microsoft.AspNetCore.Mvc.Versioning package.
✅ Supported methods:
application/vnd.company.v1+json
services.AddApiVersioning(options => {
options.ReportApiVersions = true;
options.AssumeDefaultVersionWhenUnspecified = true;
options.DefaultApiVersion = new ApiVersion(1, 0);
});
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pplication/vnd.company.v1+json services.AddApiVersioning(options => { options.ReportApiVersions = true; options.AssumeDefaultVersionWhenUnspecified = true; options.DefaultApiVersion = new ApiVersion(1, 0); });
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: SP.NET Core selects the response format based on the Accept header. JSON is the default. To add XML: services.AddControllers() .AddXmlSerializerFormatters(); ccept: application/xml
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: form Source Attribute Body [FromBody Query string [FromQuer Route [FromRout Form data [FromForm Header [FromHear ASP.NET Core infers the source when possible.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
SP.NET Core infers the source when possible.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: For large uploads, use IFormFile, Stream, or read from Request.Body for streaming. For downloads, return FileStreamResult. Enable buffering or streaming to avoid memory overload.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use UseExceptionHandler middleware or custom ExceptionMiddleware.
You can also create a global error handler:
app.UseExceptionHandler(config => {
config.Run(async context => {
// Log and return problem details
});
});
Or use ProblemDetails for structured error responses.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pp.UseExceptionHandler(config => { config.Run(async context => { // Log and return problem details }); }); Or use ProblemDetails for structured error responses.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use proper status codes:
return Ok(result);
return NotFound();
return BadRequest(ModelState);ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
public ActionResult<Product> Get(int id) { ... }
Prefer ActionResult<T> for simpler, strongly-typed APIs.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
NotFound() : Ok(product); ✅ Improves scalability and performance.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
SP.NET Core supports full async/await pattern for IO-bound tasks.
[HttpGet]
public async Task<ActionResult<Product>> GetAsync(int id) {
var product = await _repo.GetAsync(id);
return product == null ? NotFound() : Ok(product);
}
✅ Improves scalability and performance.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Enable CORS (Cross-Origin Resource Sharing) to allow client apps from
different domains:
services.AddCors(options => {
options.AddPolicy("AllowFrontend", builder =>
builder.WithOrigins("
.AllowAnyHeader()
.AllowAnyMethod());
});
app.UseCors("AllowFrontend");
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: It can enforce rate limiting to prevent abuse and throttling to limit the number of requests a client can make.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Use Swashbuckle.AspNetCore or NSwag for generating Swagger docs. services.AddSwaggerGen(); app.UseSwagger(); app.UseSwaggerUI(); Supports: Auto-generated OpenAPI docs Try it out interface Versioning support
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: pp.UseSwagger(); pp.UseSwaggerUI(); Supports: Auto-generated OpenAPI docs Try it out interface Versioning support
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
+ HttpClient.
var client = _factory.CreateClient();
var response = await client.GetAsync("/api/products");ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
services.AddAuthentication(JwtBearerDefaults.AuthenticationSch
eme)
.AddJwtBearer(options => { ... });
[Authorize(Roles = "Admin")]
providers.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: HTTPS: Enforced via UseHttpsRedirection() CORS: Limit origins using policies Anti-forgery: Usually not needed for APIs unless using cookies (use ValidateAntiForgeryToken) Use authentication + authorization checks for all endpoints
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: DTOs decouple internal models from API contracts. Use AutoMapper for mapping: CreateMap<Product, ProductDto>(); var dto = _mapper.Map<ProductDto>(product);
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Avoid breaking changes to existing endpoints. Use new versions for changes in contracts. Maintain old versions as long as needed. Ensure documentation and clients are updated accordingly.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Example with EF Core:
modelBuilder.Entity<Product>()
.Property(p => p.RowVersion).IsRowVersion();
Return 409 Conflict if concurrency exception is caught.
Model Binding & Validation
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Model binding in ASP.NET Core maps incoming HTTP data to C# parameters or model
properties.
🔍 Sources considered:
ASP.NET Core automatically binds data based on parameter types and attributes
([FromBody], [FromQuery], etc.).
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: SP.NET Core automatically binds data based on parameter types and attributes ([FromBody], [FromQuery], etc.).
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
form fields.
or JSON body.
public IActionResult Create([FromBody] Product product)ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use a custom model binder when default binding doesn’t work (e.g., custom formats,
headers).
public class CustomBinder : IModelBinder {
public Task BindModelAsync(ModelBindingContext context) {
// Custom logic here
}
}
Register with [ModelBinder] or globally in Startup.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
[FromQuery], etc.)
You cannot bind multiple [FromBody] parameters in a single action.
Common sources:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Decorate models with attributes: public class User { [Required] [StringLength(50)] [EmailAddress] public string Email { get; set; } } Used in both MVC and API for validation.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Server-side: Always performed on the server; use ModelState.IsValid. Client-side: HTML5 + jQuery Unobtrusive Validation (for MVC/Razor Pages). Client-side validation improves UX, but server-side is essential for security.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Create custom rules by inheriting ValidationAttribute:
public class MustBeEvenAttribute : ValidationAttribute {
public override bool IsValid(object value) {
return (int)value % 2 == 0;
}
}
Use like:
[MustBeEven]
public int Number { get; set; }ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use for cross-field validation within a model:
public class Product : IValidatableObject {
public string Name { get; set; }
public decimal Price { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext
context) {
if (Price < 0) {
yield return new ValidationResult("Price must be
positive");
}
}
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
public class UserValidator : AbstractValidator<User> {
public UserValidator() {
RuleFor(x => x.Email).NotEmpty().EmailAddress();
}
}
Register with:
services.AddFluentValidationAutoValidation();
✅ Offers more readable and testable validation logic than data annotations.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
ModelState.IsInvalid.
ModelState.IsValid.
if (!ModelState.IsValid) return View(model);ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Used to check if bound model passed validation: if (!ModelState.IsValid) { return BadRequest(ModelState); } MVC automatically adds errors to ModelState based on validation attributes.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: SP.NET Core supports binding nested properties: public class Order { public Customer Customer { get; set; } public List<Product> Products { get; set; } } Works seamlessly from JSON or form data if property names match.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Use [Required] for non-nullable fields. For optional values, use nullable types. Use ModelState to report and handle missing/invalid fields. Return custom error messages if needed.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Model binding does not sanitize input — it binds raw data. 🛡 To prevent attacks (XSS, injection), sanitize: Strings: HTML encode output (@Html.Encode) Manually clean input before use Use antivirus/malware scanners for uploaded files
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Used for file uploads from forms (not [FromBody]):
public IActionResult Upload(IFormFile file)
{
var path = Path.Combine("uploads", file.FileName);
using var stream = new FileStream(path, FileMode.Create);
file.CopyTo(stream);
}
📝 For multiple files:
List<IFormFile> files
Configuration & AppSettings
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Development, Production).
🔧 ASP.NET Core loads them automatically based on the environment:
ASPNETCORE_ENVIRONMENT=Development
✅ Loaded in order of precedence, where later files override earlier ones.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: SPNETCORE_ENVIRONMENT=Development ✅ Loaded in order of precedence, where later files override earlier ones.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Production)
ASP.NET Core uses the ASPNETCORE_ENVIRONMENT variable to determine the runtime
environment.
Supported environments (by convention):
Environment-specific logic can be applied:
if (env.IsDevelopment()) { ... }
Also used to load:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
SP.NET Core uses the ASPNETCORE_ENVIRONMENT variable to determine the runtime
environment.
Supported environments (by convention):
Environment-specific logic can be applied:
if (env.IsDevelopment()) { ... }
lso used to load:
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
✅ ASP.NET Core supports hierarchical override of config sources:
MyApp__Logging__LogLevel__Default=Warning
dotnet run --Logging:LogLevel:Default=Debug
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Inject IConfiguration anywhere:
public class MyService {
private readonly string _apiKey;
public MyService(IConfiguration config) {
_apiKey = config["MySettings:ApiKey"];
}
}
You can also access nested settings via config.GetSection("MySettings").
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Bind config to strongly typed objects:
public class MySettings {
public string ApiKey { get; set; }
public int Timeout { get; set; }
}
services.Configure<MySettings>(config.GetSection("MySettings"));
Use via IOptions<MySettings>.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
IOptionsMonitor<T>)
services.
public MyService(IOptions<MySettings> options) {
var settings = options.Value;
}ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: User Secrets (for local dev): dotnet user-secrets init dotnet user-secrets set "MySettings:ApiKey" "secret" Azure Key Vault: builder.Configuration.AddAzureKeyVault(...); ✅ Secure sensitive data like API keys, connection strings, tokens.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
In appsettings.json:
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
Supports built-in providers: Console, Debug, EventSource, Azure, etc.
Custom configuration through ILogger<T>.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Stored under "ConnectionStrings" section in appsettings.json:
"ConnectionStrings": {
"DefaultConnection":
"Server=.;Database=AppDb;Trusted_Connection=True;"
}
Read via:
var conn = config.GetConnectionString("DefaultConnection");
Or inject via Options pattern.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
JSON files support live reload:
builder.Configuration.AddJsonFile("appsettings.json", optional:
false, reloadOnChange: true);
IOptionsMonitor<T> automatically updates bound values when config changes.
🔁 Does not work with all sources (e.g., env vars, command line).
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Using POCOs and Options pattern allows type-safe config: services.Configure<MySettings>(config.GetSection("MySettings")); Use [Required], [Range], etc., to add validation.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
You can validate bound config using IValidateOptions<T>:
public class MySettingsValidator : IValidateOptions<MySettings> {
public ValidateOptionsResult Validate(string name, MySettings
options) {
if (string.IsNullOrWhiteSpace(options.ApiKey)) {
return ValidateOptionsResult.Fail("ApiKey is
required.");
}
return ValidateOptionsResult.Success;
}
}
Register with DI:
services.AddSingleton<IValidateOptions<MySettings>,
MySettingsValidator>();
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: SP.NET Core supports multiple configuration providers: JSON (default) Environment Variables Command Line Args INI files XML files In-memory Azure App Configuration Azure Key Vault Secrets Manager Each can be chained with priority.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
? "fallback";
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: Use default values in POCOs or fallback logic: public class MySettings { public string ApiKey { get; set; } = "default-api-key"; } Or: var apiKey = config["MySettings:ApiKey"] ?? "fallback";
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
uthentication & Authorization (JWT, Identity)
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
✅ Best practices:
_logger.LogInformation("Token: {Token}", Mask(token));
Authentication & Authorization
(JWT, Identity)
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
action (What are you allowed to do?)
In ASP.NET Core, both are handled via middleware and attributes like [Authorize], roles,
and policies.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: ction (What are you allowed to do?) In ASP.NET Core, both are handled via middleware and attributes like [Authorize], roles, nd policies.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
SP.NET Core Identity provides a complete solution for:
✅ Setup:
dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
In Startup or Program.cs:
services.AddIdentity<IdentityUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
JWT (JSON Web Token) is a compact, URL-safe token format used for authentication.
✅ Configure JWT auth:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options => {
options.TokenValidationParameters = new
TokenValidationParameters {
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
IssuerSigningKey = new
SymmetricSecurityKey(Encoding.UTF8.GetBytes("your-secret"))
};
});
Use [Authorize] to secure endpoints.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
✅ Role-based:
[Authorize(Roles = "Admin")]
✅ Policy-based:
services.AddAuthorization(options => {
options.AddPolicy("CanEdit", policy =>
policy.RequireClaim("EditPermission"));
});
Then use:
[Authorize(Policy = "CanEdit")]
Policy-based gives more flexibility (custom requirements, claims, logic).
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
.Value;
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: dd claims when creating identity: var claims = new List<Claim> { new Claim(ClaimTypes.Name, user.UserName), new Claim("Permission", "Edit") }; ccess in code: var claim = User.FindFirst("Permission")?.Value;
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Used in traditional MVC apps for session-based auth.
services.AddAuthentication(CookieAuthenticationDefaults.Authenticati
onScheme)
.AddCookie(options => {
options.LoginPath = "/Account/Login";
});
On login:
await HttpContext.SignInAsync(principal);
Cookies are stored in the browser and sent with each request.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: wait HttpContext.SignInAsync(principal); Cookies are stored in the browser and sent with each request.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Use built-in providers:
services.AddAuthentication()
.AddGoogle(options => {
options.ClientId = "...";
options.ClientSecret = "...";
});
Also supports:
Use RemoteAuthenticationHandler<T> or Identity scaffolding.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: lso supports: Facebook Microsoft Twitter OpenID Connect Azure AD Use RemoteAuthenticationHandler<T> or Identity scaffolding.
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Used with JWT to renew access tokens after expiration without logging in again.
You must manually implement refresh token logic (not built-in to Identity).
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
✅ Configure expiration:
Expires = DateTime.UtcNow.AddMinutes(30)
✅ Use refresh tokens to handle expiration.
ASP.NET Core ASP.NET Core Tutorial · ASP.NET Core
Answer: [Authorize]: Requires authenticated user [Authorize(Roles = "Admin")]: Requires role [AllowAnonymous]: Allows access without login Example: [Authorize] public IActionResult Dashboard() { } [AllowAnonymous] public IActionResult Login() { }
In a production ASP.NET Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.