ASP.NET MVC 4 is the fourth major version of the ASP.NET Model-View-Controller platform for web applications.

learn more… | top users | synonyms

0
votes
0answers
10 views

Cascaded DDL “Default Select List” [on hold]

I'll start by saying ddlDivision is cascaded from ddlLeague ...
1
vote
1answer
35 views

Admin class for monitoring blog users

I have an admin class that controls when a user logs in and creates a new blog post. I am wondering if there is anything I can do to improve this class. Is there any way to reduce the code? Is there ...
2
votes
0answers
52 views

Knowing who is the user in every request (in every action and every view)

First: I have many model classes that are mapped from/to tables using EF. Two of them are User and UserCookie, which are stored ...
1
vote
0answers
48 views

Extending the MVC Routecollection

I'm currently developping an MVC framework on which I will be writing my websites. This is done through the usage of a starter kit. In standard MVC, your routes are registered like the following: ...
3
votes
0answers
53 views

Updating Related Data the MVC/EF Way

I have an ASP.NET MVC Controller, the relevant parts of which appear here: ...
2
votes
2answers
117 views

ASP.NET MVC return early from an action that returns a model

Consider the following code segment written by a coworker of mine: ...
4
votes
1answer
53 views

FormBuilder Code Make More Genereic

I want to construct a form builder for an internal project in mvc4. I am using partial views to load the various controls. However I feel that having ten or 20 action-results in my HomeController ...
3
votes
2answers
77 views

Multiple loops versus multiple stringbuilders

I've come across the following piece of code in a Razor view ...
4
votes
0answers
188 views

PreWarmCache for MVC Application with Stopwatch Infinite Loop

I used the information from the article "Auto-Start ASP.NET Applications (VS 2010 and .NET 4.0 Series)" to create a background task that runs on an infinite loop. Ultimately, this program is going to ...
3
votes
3answers
394 views

Entity Framework with multiple connections open?

I'm learning Entity Framework and I'm wondering if this code is the proper way of doing this. Basically this is my attempt at refactoring a very long controller in ASP.Net MVC 4. I'm using Entity ...
5
votes
1answer
155 views

Where to put hidden fields when displaying entities properties in a table?

Let's say that I have a view, whose purpose is to show a table with some information about a person entity. The view contains a form with an input element that the user can use to add a new person to ...
5
votes
3answers
217 views

Calculating total sales from each member

I am building a new system that is using some tables from an old system. For each user on this new system, I need to go to the old system and total up their sales. Currently it takes between 2-5 ...
5
votes
1answer
568 views

Model Design for MVC4 Applications using Entity Framework Code First

I would like to put the following design to your consideration. This is the pattern I use to follow when I'm building a Model and Data Access Layer for an MVC Application (using Entity Framework 5). ...
1
vote
1answer
95 views

Class to Return Single Integer

I have a class used to return a single integer, but think there is room for improvement. The class should only return a single row every time and if no row is found it might be a good idea to throw an ...
7
votes
1answer
81 views

Customized Template Login

While the MVC4 template provided by Microsoft is useful, I feel there are a few scenarios that should be covered to help out users trying to log in. Allow the user to log in with their email address ...
11
votes
3answers
212 views

Tracking sports statistics

I am designing a new application to track sports statistics with code-first migration. I have the bare minimum POCO setup. The problem is that I am not happy with the design specifically how the ...
3
votes
1answer
527 views

Populate Drop Down List from SQL Database

I am populating a drop down list from my SQL database. List should be able to be displayed with active only, inactive only or both at the same time. OfficeRepository.cs: ...
4
votes
1answer
122 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. ...
8
votes
2answers
337 views

Accessing server side variables in views and JavaScript

Here is the snippet of my code: /Views/Emp/EditEmp.aspx ...
4
votes
1answer
190 views

How can I simplify these if/else clauses?

I have a few if, else-if, else clauses. The only ...
2
votes
2answers
113 views

Returns Office Details from Database

I am building an Administration web site for the Office details in my database. Right now, I am just trying to display the office details. ...
0
votes
1answer
30 views
7
votes
3answers
433 views

Ternary extension method

I created the following HtmlHelper extension method for my Asp.Net MVC Razor views because the ternary syntax sucks when you need to use it intermixed with markup. Is there a better way to write this ...
0
votes
0answers
53 views

Adding viewstate based property and implication in future converstion to MVC in ASP.NET forms project

Supposedly adding another viewstate based property in user control (riddled with similar properties) incur technical debt in future effort to convert projects to MVC (comment made by one of my ...
2
votes
0answers
90 views

What can I do better in this ViewModel Creator?

I'm currently creating a ASP.NET MVC page in C#. I want to hide everything regarding the creation of our "models" and "viewmodels". I have seen much of the fancy stuff regarding Dependency ...
1
vote
0answers
1k views

Code First/Database First Entity Framework MVC [closed]

The following example is taken from the book Pro ASP.NET MVC 4 - Adam Freeman. This book does a good job going over the basics of the MVC framework. In it a ...
7
votes
1answer
878 views

Is this nesting of partial views poor design?

I feel like using this many partial views where a view renders a partial that renders a partial is just digging a hole of poor design, so I'm looking for any suggestions or guidance as to if this is ...
6
votes
2answers
2k 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 ...
1
vote
1answer
156 views

Inserting using multiple contexts into LocalDB

I've written this ActionResult to model an Order that goes through. I couldn't think of another way to write this without using context ...
3
votes
1answer
99 views

Retrieving statistics about URL clicks

I'm pretty new to ASP/MVC but have had some prior programming experience. I am trying to retrieve statistics about URL clicks - total clicks and unique clicks by IP address. I started with: ...
5
votes
2answers
14k views

Update only modified fields in Entity Framework

I'm working on a website on ASP.NET MVC4 and EF5. I want to ensure that only modified values are updated in the database. I'm using a unit of work pattern and repositories for data work. Here's the ...
5
votes
1answer
163 views

MVC4 Routes, using Default

Should I leave the Default Route in if it's not adding any benefit? I have a RouteConfig.cs file that looks like this: ...
7
votes
2answers
557 views

Reduce spaghetti code in ASP.NET MVC

I just started working with asp.net mvc a few weeks ago, and I'm finding that it can be very easy to write spaghetti code in the controllers. For my first project, I created a very simple view with a ...
4
votes
1answer
4k views

Unit of Work with Repository Pattern MVC 5 & EF 6

I put together a sample of how I am using the Unit of Work & Repository pattern based on my understanding. Can anyone please let me know if I am implementing this the correct way? If I am not, how ...
2
votes
1answer
542 views

Improving MVC 4 DropDownList

I'm currently populating my drop downlists like this... ...
1
vote
1answer
47 views

Using 'dynamic' to save lines

I am pushing an Excel file to the server and then reading it's contents. XLS and XLSX files need to be read differently, but the DLL that I'm using has the EXACT same function calls for both types. If ...
2
votes
1answer
127 views

Need reviews for an authentication system

AccountController Code: ...
4
votes
1answer
2k views

Unit of work, Ninject, Repository and WebAPI implementation

after recently getting a bulk of work done on my WebAPI service layer, I thought I'd post some of my working on here for you guys to tear apart, generally, most of it 'feels' mostly okay, but I know ...
6
votes
1answer
6k views

Entity Framework using Repository Pattern, Unit of Work and Unity - viable approach?

Using a combination provided from this example and this implementation, I'm creating a solution that decouples the UnitOfWork class from the individual ...
3
votes
0answers
232 views

Acceptable Way to Navigate in ASP.NET MVC 4 in SPA-like App

I'm getting back into web development, and I'm creating a mobile-friendly web app. I'm trying to make it SPA-like in the sense that I don't load new pages for each action the user takes. As my ...
1
vote
1answer
271 views

Creating models manually in mvc

I am creating my models manually. I have five tables in my database as follows : 1. Members 2. MemberTypeMasters 3. Payments 4. Relationships 5. StatusMasters ...
2
votes
1answer
3k views

When to use separate DBContext classes?

I know that the DBContext represents a session (Unit-Of-Work and Repository) with the database, however I an unsure as to when I should have a different DBContext. Currently, I have a separate ...
6
votes
2answers
4k views

MVC Layered Project Structure

We are starting a new web project using C# / MVC 4 and Entity Framework 5 for data access. I've decided to go with an n-layered approach for the structure of the project and I would like some feedback ...
4
votes
1answer
1k views

DbSet<T> IncludeAll method

The Problem As an ASP.NET MVC4 developper, I'm using Entity Framework a lot. Considering performance I often use lazy loading for my models. ...
3
votes
2answers
349 views

Cookie wrapper in MVC4

I'd like to create a cookie wrapper in my application to help support a DRY approach to coding common cookie methods, provide IntelliSense for cookie-type properties (keys), and protect against ...
3
votes
1answer
470 views

Multiple Ajax Requests per MVC 4 View

I'm using the repository pattern with a context and ninject as the IOC. I have a service which handles getting and setting page properties in the database. ...
1
vote
1answer
281 views

Modeling a decision tree-like form

A picture says more than a thousand words, so here's a mock-up. The actual choices are different, this is just a sample. A user first has to choose between Red, Blue and Green. Upon selecting an ...
10
votes
1answer
2k views

Generic ASP.NET MVC controller that generates many pages

I recently set out to create an open-source ASP.net MVC web development framework. Specifically, I wanted to automate some of the tasks associated with the creation of data-driven applications. I've ...
4
votes
1answer
3k views

custom System.Web.Http.AuthorizeAttribute

I've hacked together what feels like a mess for an authorize attribute to secure web api methods. The code appears to be functionaly correct; passing the unit tests in place. The code has me worried ...