Model-View-Controller for the ASP.NET framework

learn more… | top users | synonyms

1
vote
1answer
96 views

Dependency Injection With Unity in MVC 5 without repository and unit of work

I want to use dependency injection with Unity in my application. I am not following repository pattern and unit-of-work (and don't want to). I also have ViewModel in my controller action method. ...
3
votes
1answer
41 views

Handling CRUD for look-up tables

I'm creating the admin portion of a project. Specifically, I am wanting to allow the users to update the look-up tables for their areas of interest. All of my look-up tables have the same structure: ...
5
votes
2answers
61 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
379 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 ...
4
votes
3answers
230 views
8
votes
1answer
592 views

Creating 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
65 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
80 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
507 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
70 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
575 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
264 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
175 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 ...
4
votes
1answer
170 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 ...
3
votes
2answers
1k 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
298 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
1k 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
731 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
138 views

Model binding with a ViewModel

I have two ViewModels with the one referencing the other: ...
8
votes
1answer
135 views
7
votes
1answer
250 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
102 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 ...
4
votes
1answer
2k 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
106 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
322 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
155 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
252 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
121 views

Concerns about my repository implementation

I have a repository called PostsRepository: ...
3
votes
1answer
281 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
52 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
79 views
4
votes
2answers
83 views
3
votes
1answer
71 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
156 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
99 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
303 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
129 views

Is my ObjectCache wrapper sound?

Wrapper: ...
8
votes
2answers
587 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
144 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
429 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 ...
5
votes
4answers
1k 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
12k 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
174 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
322 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
361 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
234 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 ...
13
votes
2answers
15k 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
3k 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
4k 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
128 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 ...