Questions tagged [asp.net-mvc]

Model-View-Controller for the ASP.NET framework

Filter by
Sorted by
Tagged with
7 votes
1 answer
310 views

Somewhat esoteric if statement in a paginated feed

I am working on the home page of a website that will have a paginated feed (much like a blog's home page). One of the requirements is that when a user navigates to a non-existent page, he or she will ...
Caster Troy's user avatar
2 votes
4 answers
3k views

Thin controller design

We have asked to keep the MVC controller as thin, so we decided to move all the service calling/business logic into the ViewModel class. But is it good approach to use a ViewModel class to make a ...
user avatar
13 votes
1 answer
41k views

Error Handling - Controller's OnException and Application_Error

I'm pretty new to MVC. Below is the code that I have added to an existing MVC 5 application. The code is using log4net to log any run-time error/exception. NOTE: I could override ...
user1552869's user avatar
5 votes
1 answer
212 views

Controller that uses a tested repository (or service)

I have a repository called PostsRepository who implements an interface called IPostsRepository: ...
Caster Troy's user avatar
2 votes
2 answers
1k views

ASP.NET MVC website that display blogs from the database by AJAX

The problem is, I have to limit the results to only 10 by default and add a "Load More" button to display 10 more results each time when user click the button. But I'm worried about users having their ...
Anonymous's user avatar
  • 123
3 votes
0 answers
1k views

Wrapper for jQuery Ajax to ensure redirects occur on clientside - Round 2

A while back I posted Wrapper for jquery ajax to ensure redirects occur on clientside on handling ajax and redirects when a server side error occurs. Since that post I've been using this module ...
dreza's user avatar
  • 6,437
14 votes
2 answers
5k views

Repository and Controller tests

Lately I have been researching how to best unit test an EF repository and given a properly tested repository, what to test in the controller. My research did not reveal many sound examples or ...
Caster Troy's user avatar
6 votes
2 answers
294 views

Repository implementation

I have a repository called PostsRepository: ...
Caster Troy's user avatar
3 votes
1 answer
2k views

Refactoring fat ASP.NET MVC Controller

I have just began porting an old project to ASP.NET MVC . In the end, I'll have a lot of controller methods like the one below, called by AJAX requests done by JQGrid objects in the pages: AJAX ...
marin's user avatar
  • 163
2 votes
1 answer
91 views

Client-side API design

I'm working on a client-side API for my ASP.net MVC application and I'm not quite sure I've got the code right. This API allows me to call server-side action methods via Ajax and I've designed it to ...
TugboatCaptain's user avatar
3 votes
1 answer
171 views

Replacing div if there is any validation error connected with the div value

I have an input group: ...
szpic's user avatar
  • 187
4 votes
2 answers
117 views

Best testing using a mocked repository

...
Caster Troy's user avatar
4 votes
1 answer
132 views

Simple blog engine for educational purposes

I am coding a simple blog engine for educational purposes. In the PostsController I have two two methods that share some common code namely, ...
Caster Troy's user avatar
17 votes
1 answer
284 views

Naming for unit tests for controller to edit posts

I am relatively new to TDD and am trying to adopt better names for my tests. I wrote the following tests abruptly and have since refactored them to the best of my ability, but despite my best ...
User 12345678's user avatar
5 votes
1 answer
553 views

ListBox Update Handling

I have UserGroups for Users to be assigned to in a ListBox in HTML form. Items from listbox can be multi-selected or completely ...
lbrahim's user avatar
  • 353
3 votes
1 answer
5k views

Send parameter to server and reload page

My first ASP.NET MVC 6 / jQuery web site - the site header has a "Change Language" selector (named LanguagePicker) - this is actually placed in a _Layout view, a ...
marin's user avatar
  • 163
2 votes
1 answer
453 views

Is my ObjectCache wrapper sound?

Wrapper: ...
Stijn's user avatar
  • 313
10 votes
2 answers
4k views

Feature-based authorization

Feature-based authorization It seems to me that if you rely on roles to authorize a web application it makes it very difficult to render UI or code based on a set of features. This means that each ...
jwize's user avatar
  • 199
3 votes
1 answer
2k views

Custom HtmlHelper to render a Grid

I have created a custom HtmlHelper to render a Grid, and it's working fine, but I know for sure that it isn't written really ...
Complexity's user avatar
24 votes
4 answers
33k views

How to write elegant conditional bits of markup in Razor views?

Suppose the following model: public class ViewBookModel { public string Title { get; set; } public string Subtitle { get; set; } } I'm currently ...
Jeroen's user avatar
  • 1,441
1 vote
1 answer
479 views

ASP.NET MVC Project Layering

This is how I imagine my project's layering: BLL Should be independent and contain only pure business logic and properties Sample Domain Model: ...
lbrahim's user avatar
  • 353
3 votes
1 answer
2k views

View Model Filling Fields

I'm currently getting into MVC, and I'm working on a simple CRUD application but to make best use of relational database layout I need to use ViewModels so things look prettier on the UI. I have a ...
Ryan McDonough's user avatar
6 votes
1 answer
4k views

Implementing HTTP Strict-Transport-Security via MVC action filter

HTTP Strict Transport Security (HSTS) is an opt-in security enhancement that is specified by a web application through the use of a special response header. Once a supported browser receives this ...
Stuart Blackler's user avatar
5 votes
2 answers
385 views

Getting list of daily team goals

The old code I had before was atrociously slow but after some advice and research I was able to take a 2-5 minutes run time down to about 5-30 seconds. That is acceptable, but still looking to have ...
James Wilson's user avatar
47 votes
2 answers
100k views

Unit of Work and Repository with Entity Framework 6

Based on the reply of this question I have created the following code. I need to check whether it's good or not. Here is my entity class: ...
Jalpesh Vadgama's user avatar
8 votes
1 answer
12k views

MVC 5 & EF 6 - Repository & Unit of Work Pattern

I have been looking through Code Review on the subject of Unit of Work and Repository patterns and realised that my implementation appears to provide very similar functionality but in reverse class ...
Matthew Hudson's user avatar
7 votes
2 answers
378 views

Refactoring Methods With Conditionals

I have always suffered with too many conditionals in some of my methods. The following is a pseudocode/skeleton of one of my method like that: ...
lbrahim's user avatar
  • 353
6 votes
1 answer
15k views

Concerned with Enums, JSON, and ASP.NET MVC

I am writing an application that uses ASP.NET MVC for its front end, and for the back end, it uses RavenDB to store data. This ...
Ciel's user avatar
  • 323
2 votes
1 answer
565 views

How can I simplify these if/else clauses?

I have a few if, else-if, else clauses. The only ...
LIK's user avatar
  • 131
2 votes
2 answers
148 views

How to declutter dependencies?

I'm running into a problem with my code in a ASP.NET MVC application. Maybe it's not a problem and I'm just being paranoid, but it seems like a problem to me (might be because I've just read the book ...
mboldt's user avatar
  • 131
5 votes
1 answer
3k views

Entity Framework, code-first repository pattern review. Where to validate?

I've been iterating on my repository pattern implementation over the course of the past 4-5 months. In my new projects I choose to use this pattern and I try to improve upon what I learned in previous ...
Ryan's user avatar
  • 151
6 votes
2 answers
12k views

Building a better Data Access Layer Class

Since I am new to MVC and the Entity Framework, I have been struggling to grasp the concept of creating useful Data and Service layers. I have come across a scenario where I believe my code has become ...
broke's user avatar
  • 233
5 votes
1 answer
186 views

Displaying alert from an action

This code works great, but I think it can be reduced. ...
SoundwaveUwU's user avatar
0 votes
3 answers
178 views

Task send options: Send Now, Send Later, Repeat (viewmodel)

I'm writing a code for my application: you can create a task, and you can choose the moment when you want to send this task (to some kind of user): Send now Send later Repeat You can select from ...
Roman Pushkin's user avatar
1 vote
2 answers
4k views

Saving data to a session

I'm a bit confused if saving the information to session code below, belongs in the controller action as shown below or should it be part of my Model? I would add that I have other controller methods ...
newbie's user avatar
  • 181
3 votes
1 answer
35k views

JQGrid with dynamic columns and server-side functionality

I have a requirement where I need to build a grid with dynamic columns. I am dealing with a large dataset so I would like to use server-side paging, sorting, filtering logic so that I render only a ...
StudentForever's user avatar

1 2 3 4
5