Model-View-Controller for the ASP.NET framework

learn more… | top users | synonyms

1
vote
1answer
94 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
58 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
53 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: ...
10
votes
3answers
632 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
0answers
38 views

Model binding with a ViewModel

I have two ViewModels with the one referencing the other: ...
7
votes
1answer
242 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
22 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 ...
2
votes
1answer
103 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 ...
4
votes
1answer
92 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
107 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
73 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 ...
10
votes
2answers
217 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 ...
5
votes
2answers
106 views

Concerns about my repository implementation

I have a repository called PostsRepository: ...
2
votes
1answer
92 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
46 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
45 views
4
votes
2answers
74 views
3
votes
1answer
63 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
141 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
70 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
67 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
71 views

Is my ObjectCache wrapper sound?

Wrapper: ...
8
votes
2answers
382 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 ...
0
votes
0answers
88 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
127 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: ...
4
votes
4answers
353 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 ...
4
votes
2answers
2k 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
128 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
106 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
120 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
203 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 ...
8
votes
2answers
4k 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
782 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
1k 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 ...
2
votes
1answer
122 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 ...
6
votes
2answers
292 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: ...
4
votes
1answer
1k 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 ...
4
votes
1answer
129 views

Avoiding redundant code in MVC view page

Based on the true condition, I am making some operations. But I want to simplify the below HTML code in a better way. ...
4
votes
1answer
191 views

How can I simplify these if/else clauses?

I have a few if, else-if, else clauses. The only ...
3
votes
1answer
365 views

Where to put common method used in controllers that calls service layer?

I have an ASP.NET MVC 5 web application using the repository pattern, and I have several controllers that need to call my _loggingService (queries audit logs) to ...
2
votes
2answers
87 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 ...
5
votes
1answer
1k 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 ...
6
votes
2answers
3k 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 ...
4
votes
1answer
96 views

How can i reduce this code?

I have a problem. This code works great, but i think it can be reduced. ...
0
votes
3answers
120 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 ...
1
vote
2answers
1k views

Does code to save data is session or cache belong in controller?

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 ...