Model-View-Controller for the ASP.NET framework

learn more… | top users | synonyms

5
votes
2answers
41 views

Use of Model and View (MVC)

I have an application using c# and MVC5, with RazorEngine. My application manages requests (orders from clients) and I need to show them in tables. To achieve this I have a Controller ...
5
votes
2answers
361 views

Abstracting a Password Service

I want to use Microsoft.AspNet.Identity's PasswordHasher but I don't want to pollute my Domain layer with knowledge of it. As ...
7
votes
0answers
141 views

Easiest way to create bootstrap modals that can run javascript in MVC5

I have an MVC5, C# application using the Razor engine. In my application I have a view, called "Index.cshtml". In this view I want to present a bootstrap modal to the user. When presented to the ...
3
votes
2answers
39 views

Refactoring IEnumerable<ValidationResult>

I have the below code which increases the code complexity. Any way to refactor it? I am trying to refactor the below code so that the CCM can be reduced for the code. i.e code complexity matrix. ...
3
votes
1answer
76 views

Null checks in view

It's really a nitty-gritty issue for me, and I have been here many times before. How could this be improved? I have a basic viewmodel for a view: ...
3
votes
3answers
491 views

Code optimzation by constant if-structure iteration removal

Below you will find the specific code that I am attempting to optimize. I have a method previous to called getCount() which, based on similar parameters as below, ...
3
votes
3answers
63 views

Account inactivity reminder

I wanted to know if this is the best approach for the Single Responsibility Principle. The responsibility of this class is to remind users whose accounts are about to expire due to inactivity. On ...
4
votes
4answers
499 views

Code refactoring to check errors in MVC

The first part of code is for me very unreadable. I tried to write in another way but I'm open to your suggestion! ...
4
votes
2answers
179 views

Is it “legit” to use a Linq query in a razor view?

I have a Linq query in my razor view like below. Its just getting contacts that belong in the group. ...
3
votes
1answer
84 views

Insert missing records in a list with LINQ

We have a table with periods, and other child tables with these periods and values for combinations of product + location. Based on selected periods, I would like to add any missing rows in the child ...
3
votes
1answer
105 views

Using readonly input fields to persist data between views

I'm building a multi-screen Ajax form in an ASP.NET MVC solution. The first screen displays some user details. If the user clicks 'edit', they are taken to the next screen where they can edit the ...
2
votes
1answer
449 views

Unit of work + repository + service layer with dependency injection

I am designing a web application and a windows service and want to use the unit of work + repository layer in conjunction with a service layer, and I am having some trouble putting it all together so ...
3
votes
1answer
202 views

n-layered application structure in asp.net mvc

I've been trying to set up an n-layered application in ASP.NET MVC 5. I've "converted" my account controller to look like this. I would like some feedback as to whether this is in the right ...
2
votes
1answer
448 views

LINQ query using StartsWith and Contains to limit the results for an autocomplete field

As a source for a jquery-ui autocomplete field, I've written this action: ...
11
votes
3answers
675 views

Returning status codes from business layer

This is what I've been doing so far in my business layer to return error messages to the user. ...
1
vote
1answer
94 views

Model binding with a ViewModel

I have two ViewModels with the one referencing the other: ...
7
votes
1answer
248 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 ...
1
vote
4answers
60 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 ...
3
votes
1answer
877 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 ...
5
votes
1answer
104 views

What should I test about a controller that uses a tested repository (or service)?

I have a repository called PostsRepository who implements an interface called IPostsRepository ...
2
votes
2answers
183 views

Is there any disadvantage of using MVC Razor Syntax codes inside a NoScript tag?

I'm creating a ASP.NET MVC Website that display blogs from the database by AJAX. The problem is - I have limit the results to only 10 by default and add a Load More button to display 10 more results ...
2
votes
0answers
139 views

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

A while back I posted an code review on handling ajax and redirects when a server side error occurs. Wrapper for jquery ajax to ensure redirects occur on clientside Since that post I've been using ...
11
votes
2answers
245 views

Concerns about the correctness of my 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 ...
6
votes
2answers
118 views

Concerns about my repository implementation

I have a repository called PostsRepository: ...
3
votes
1answer
184 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 ...
2
votes
1answer
48 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 ...
3
votes
1answer
66 views
4
votes
2answers
82 views
3
votes
1answer
70 views

Making Add and Edit DRY

I am coding a simple blog engine for educational purposes. In the PostsController I have two two methods that share some common code namely, ...
13
votes
1answer
149 views

How can I better name my tests?

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 ...
5
votes
1answer
85 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 ...
3
votes
1answer
125 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 ...
2
votes
1answer
94 views

Is my ObjectCache wrapper sound?

Wrapper: ...
8
votes
2answers
481 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 ...
1
vote
0answers
132 views

WebApi synchronize database (EF 6) access

I'm working on an ASP.Net MVC 5 /WebApi 2 project. I'm using EF 6 code first for my database access. I've a WebApi action method in which I've to update some data in my database based on the request. ...
2
votes
1answer
299 views

Custom HtmlHelper to render a Grid

Edited: I've edited my code with the comments which are given by 'Mat's Mug'. Already a huge thanks for that. However, I've not done all the recommondations he adviced. Things which I've not done: ...
5
votes
4answers
655 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 ...
5
votes
1answer
8k views

Simple Authentication in ASP.NET MVC 5

I am building an ASP.NET MVC 5 application and, for reasons which are irrelevant at this point, I am attempting to build my own means of authenticating users. I'm still very new to programming, ...
1
vote
1answer
155 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: ...
2
votes
1answer
219 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 ...
4
votes
1answer
270 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 ...
5
votes
2answers
222 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 ...
10
votes
2answers
11k 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: ...
1
vote
2answers
2k views

Converting Anonymous To Dynamic [closed]

I have a extension method like following that takes Anonymous type objects and returns it after converting into ExpandoObject which falls under ...
7
votes
1answer
3k 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 ...
3
votes
1answer
127 views

How should I name a mapper or manager?

Recently I was reading a book called Clean Code by Robert C. Martin. There is a chapter called Meaningful Names that started me thinking if I was doing this right. I know there isn't one good way to ...
7
votes
2answers
306 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: ...
5
votes
1answer
2k 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 ...