
Q121
Q121 What is the purpose of the [Authorize] attribute in ASP.NET MVC?
Restrict access to routes
Enable authentication
Handle model validation
Secure Razor views
Q122
Q122 What is Cross-Site Request Forgery (CSRF)?
A database attack
A form of XSS attack
An attack where unauthorized commands are performed on behalf of a user
A form validation error
Q123
Q123 How do Anti-Forgery tokens protect against CSRF attacks in ASP.NET MVC?
They encrypt sensitive data
They validate user identity
They ensure that a form request is from the authenticated user
They block unauthorized access
Q124
Q124 What is the purpose of HTTPS in ASP.NET MVC applications?
To optimize routing
To secure data in transit
To restrict controller access
To simplify model binding
Q125
Q125 How do you enable Anti-Forgery tokens in a Razor view?
@Html.EnableAntiForgeryToken()
@Html.AntiForgeryToken()
@Html.AddCSRF()
@Html.EnableCSRF()
Q126
Q126 How do you implement custom role-based authorization in ASP.NET MVC?
Create a custom AuthorizeAttribute
Add roles in Web.config
Use HttpContext.SetRole()
Modify RouteConfig
Q127
Q127 How do you enforce HTTPS for a controller in ASP.NET MVC?
Use the [HttpsRequired] attribute
Use the [RequireHttps] attribute
Define HTTPS in RouteConfig
Set HTTPS in Web.config
Q128
Q128 A [RequireHttps] attribute throws an error on localhost. What is the issue?
HTTPS is not enabled
Route is missing
Anti-Forgery token is missing
Certificate is invalid
Q129
Q129 An Anti-Forgery token validation fails. What could be the issue?
Token mismatch
Route conflict
Controller is missing
Invalid Razor syntax
Q130
Q130 What is bundling in ASP.NET MVC?
Combining multiple scripts or stylesheets into a single bundle
Caching views
Minimizing routing
Combining models
Q131
Q131 How does caching improve performance in ASP.NET MVC?
By storing frequently used data
By validating model bindings
By optimizing Razor syntax
By managing routes dynamically
Q132
Q132 What is output caching in ASP.NET MVC?
Storing HTML responses for reuse
Caching database queries
Caching controller actions
Storing Razor syntax
Q133
Q133 How do you enable output caching for an action in ASP.NET MVC?
Use the [Cache] attribute
Use the [OutputCache] attribute
Define caching in Web.config
Set caching in RouteConfig
Q134
Q134 How do you implement bundling in ASP.NET MVC?
Add bundles in the BundleConfig.cs file
Define bundles in RouteConfig
Use the @Html.Bundle() method
Add bundles in the controller
Q135
Q135 Bundling is not working in production. What could be the issue?
Minification is disabled
Debug mode is enabled
BundleConfig is missing
All of the above
Q136
Q136 Cached data is not being updated after changes. What could be the issue?
Cache duration is too long
Controller action is missing
OutputCache is invalid
BundleConfig is incorrect
Q137
Q137 What is the purpose of unit testing in ASP.NET MVC?
Test database performance
Test individual components
Test Razor syntax
Test server configurations
Q138
Q138 How does Dependency Injection improve testability in ASP.NET MVC?
By enabling the use of mocks
By reducing database calls
By optimizing routes
By simplifying view rendering
Q139
Q139 What is the role of a mocking framework in unit testing?
It handles routing
It creates fake dependencies
It validates Razor syntax
It simplifies model binding
Q140
Q140 How do you test a controller action using NUnit?
Create a mock HttpContext
Call the action directly and assert the result
Use RouteConfig to define the test
Create a Razor view for testing
Q141
Q141 How do you mock a DbContext for unit testing?
Use InMemoryDatabase
Use a mocking library
Manually create stubs
Both A and B
Q142
Q142 A unit test for a controller fails to execute. What could be the issue?
Dependency is not mocked
Route is undefined
ViewBag is missing
Razor syntax is incorrect
Q143
Q143 A mocked service in a unit test returns null. What is the issue?
Mock setup is incorrect
Service is not registered
Route is not defined
Controller is invalid
Q144
Q144 What is a common challenge in building large-scale ASP.NET MVC applications?
Handling complex routing
Managing multiple controllers
Ensuring loose coupling
Optimizing Razor syntax
Q145
Q145 How can you improve scalability in an ASP.NET MVC application?
Implement caching
Use asynchronous programming
Implement Dependency Injection
All of the above
Q146
Q146 What is a critical factor for maintaining performance in an enterprise MVC app?
Using Anti-Forgery tokens
Efficient database interactions
Creating complex Razor views
Minimizing controller actions
Q147
Q147 How do you handle dynamic routing in an ASP.NET MVC application?
Define routes in RouteConfig
Implement IRouteHandler
Use the [Route] attribute
Create custom routes in Global.asax
Q148
Q148 How do you structure an ASP.NET MVC project for a modular application?
Use areas for grouping related features
Add all controllers in a single folder
Define routes in views
Separate controllers and views in different projects
Q149
Q149 A large ASP.NET MVC app has slow response times. What could be the issue?
Too many database calls
Excessive view rendering
Incorrect route definitions
All of the above
Q150
Q150 How do you resolve memory leaks in an ASP.NET MVC application?
Use Dependency Injection
Dispose of unmanaged resources
Optimize Razor syntax
Enable caching