Questions tagged [asp.net-mvc-3]

ASP.NET MVC 3 is the third major version of Model-View-Controller extension for developing web applications in a .NET framework

Filter by
Sorted by
Tagged with
11
votes
1answer
2k views

Efficient way to deal with maintaining Many:Many relationships in EF Code-First

I've got this all working, but it seems to be quite long-winded, and I thought I'd post here and see if I'm doing it wrong... I have a M:M relationship between an Installer and a MasterInstance. The ...
28
votes
4answers
32k views

Separating Models and ViewModels

I have a central domain assembly which contains various rich domain models. Lots of business logic, etc. To keep this example simple, here's probably the simplest one: ...
3
votes
2answers
3k views

User Login Logic

I want to see if this is as streamlined as possible. Most of the logic is accomplished through methods in the model. The controller does one of four things: redirects new users to registration ...
6
votes
1answer
1k views

MVC Async Action Invoking Workflow

I've just started working with Workflow (WF4) and have been playing with an idea of using it in MVC3.0 controller actions to see if it improves the maintainability of complex actions; also potentially ...
7
votes
1answer
3k views

Model validation from within the Service Layer

I'm interested in the idea of not having my BLL dependent on ASP.NET MVC. This means that I would like to have model binding occur within my service layer. But I want to take advantage of ASP.MVC's ...
27
votes
1answer
7k views

Fluent LinkedIn REST API client interface design

There is a handful of LinkedIn clients written in C# on the NuGet package library, but as far as I can tell, most only do authentication via LinkedIn. I found a couple which offer a LinkedIn REST API ...
35
votes
7answers
130k views

Dynamic filtering and sorting with Entity Framework

I'm developing an application using ASP.NET MVC 3 and Entity Framework 4.1. In that application I have a lot of paged lists. Users can filter and sort these lists. This results in code like the one ...
5
votes
2answers
864 views

Locating a list of parts

I have an ASP.NET MVC3 web application that displays a list of parts (a part is a simple entity with a number and a description). I have updated the action method to support filtering and paging: <...
2
votes
1answer
3k views

Right usage of ViewModels in MVC

I'm new to MVC and i'm having some difficulty on understanding the proper usage of ViewModels and Controllers. I have this ...
6
votes
3answers
28k views

Passing an array of values in Url.Action

I need to pass an array of values in Url.Action. Currently I'm doing: ...
11
votes
1answer
45k views

Custom Authentication, Authorization, and Roles implementation

I've got an MVC site, using FormsAuthentication and custom service classes for Authentication, ...
61
votes
4answers
55k views

EF Code First with Repository, UnitOfWork and DbContextFactory

I am about to >explode< :) due to amount of reading on this subject... My head hurts, and I need some honest opinions... There is a similar question/review that I noticed, but I believe my approach ...
7
votes
1answer
3k views

ASP.NET MVC 3 ModelBinder with string sanitizing

I need to allow incoming HTML in string parameters in my projects action methods, so we have disabled Input Validation. I have a good HTML sanitizer; the review I am interested in is the way I bound ...
2
votes
1answer
238 views

Using IDisposable to stripe a table

What are your thoughts on using an IDisposable to stripe an HTML table like so? It's a blatant abuse of IDisposable but this ...
17
votes
1answer
22k views

Using 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 ...
10
votes
1answer
17k views

Custom route for writing friendly URLs in ASP.NET MVC 3

I'm trying to build friendly URLs like /post/1/my-first-post. I started out with building my links like this: ...
14
votes
2answers
1k views

“Pluggable” routes in ASP.NET MVC

How do I handle multi-tenancy with routes in ASP.NET MVC? The application is a multitenant ASP.NET MVC 3 application. Tenants are identified based on hostname so this does not interfere with routing. ...
1
vote
1answer
599 views

MVC pager helper

I've got this MVC pager helper and it's working exactly as expected. Is there a prettier or more performant way to build this out? Also, I know that the StringBuilder might not be the best way. Would ...
0
votes
1answer
151 views

Model with complex/simple properties

I have a model with a number of complex/simple properties that has a corresponding strongly typed view, that calls EditorFor to a custom editor template view for ...
4
votes
2answers
965 views

Drop-down for populating a list of cities

I have created a drop-down to populate a list of cities. Everything works fine, but I would like to know better ways of doing this. Also, please let me know if it is possible to create the same drop ...
7
votes
2answers
917 views

MembershipProvider with Entity Framework and IoC

I am using Castle Windsor as my IoC container and I registered it as a DependencyResolver to let the MVC framework know about it. With the Entity Framework I have ...
4
votes
4answers
489 views

Email confirmation model

Email<input type="text" id="email" /><br /> Re-enter Email<input type="text" id="confirm-email" /> I'm thinking that I want a model so that I ...
11
votes
1answer
4k views

Implementing a generic DropDownList attribute and templating solution

My goal was to be able to render my view models using a standard Object.cshtml editor and display template. In order to do so I needed to be able to always call <...
5
votes
3answers
22k views

ASP.NET MVC using Repository pattern

I am just trying to use ASP.NET MVC using repository pattern. Am I doing something wrong here? Model - Contains the model ...
9
votes
2answers
9k views

Conditional string building

Essentially I'm taking a number of checkboxes off of my view, adding them to a Dictionary<string, bool>, and writing out the ...
1
vote
1answer
10k views

Using AutoMapper in ASP.Net MVC

I'd like to check my understanding and usage of the AutoMapper in my ASP.Net MVC app. I setup the maps in Application_Start: ...
2
votes
1answer
931 views

Use of Ninject and an injectable DataLayer in MVC3

I'm trying to make an MVC3 application with an exchangeable data layer. I currently have this in a single file (Global.asax.cs) for brievity. It seems to be working as I want but as I'm new to DI I ...
2
votes
2answers
302 views

Creating 28 checkboxes with a common name and different values

There are 28 check boxes that are given a common name and have different values: <input type="checkbox" name="Schedules" id="checkbox1" value="1"> In ...
2
votes
1answer
685 views

Amazon S3 pass-through controller

I am building a website that uses Amazon S3 to host its image (and other) files. I require that images displayed on the website look like they come from my site and not from Amazon (so we are talking ...
3
votes
1answer
3k views

Is this a workable UnitOfWork with Repository pattern design?

I am building a web app with using UOW and Repository pattern. I have seen many different samples and found each one to be different, so not sure which is the correct way to go. I have a basic ...
4
votes
3answers
1k views

View model with properties that represent years and months

I have a view model with properties that represent years and months: ...
7
votes
2answers
4k views

Custom Authentication Attribute

I was trying to find a way to redirect to different pages on authorization and authentication failure. I found this to be a possible solution. However, I ended with a different solution by myself. It ...
8
votes
1answer
229 views

Is this appropriate way to pass data from presentation to application layer?

What is the best practices to pass data from presentation to application layer? Currently I have something like this: in presentation layer: the controller: ...
6
votes
1answer
480 views

The way to realise data access

There are a several articles about true data access in MVC. I tried to make the best one according to the architecture flexibility. My way is following: ADO .NET Entity Data Model (*.edmx from Entity ...
4
votes
2answers
16k views

Search and filter in MVC3 Razor using Linq

This code works fine, but I just don't like all the if else. If I keep adding field to filter, it's going to get messy. I am not using EF and cannot on this. ...
4
votes
2answers
692 views

Controller for searching with certain parameters

In the index view a user can search with any combination of one to all of the following parameters: firstname, lastname or ...
4
votes
1answer
531 views

Loading data from a remote app

I have a method which loads data from a remote app (send TCP request and parse response). Now, I have a simple class for sending a TCP request: ...
5
votes
2answers
7k views

Is it ok to use HttpContext inside View?

I have a pretty common issue: I need to know the name of current user and also name of the current controller so I can highlight/disable some links. Here's some solutions I found by myself: Get all ...
1
vote
1answer
904 views

Optimising multi-part LINQ to Entities query

I have inherited an application which uses LINQ-to-Entities for ORM and don't have a great deal of exposure to this. There are many examples like this throughout the application. Could you tell me ...
2
votes
2answers
384 views

Am I approaching this ASP.Net MVC/Entity Framework pattern incorrectly?

I have experience is C#/ASP.NET, and I've done MVC in Ruby On Rails, so I figured making the jump to ASP.NET MVC would be a breeze. Unfortunately, I'm second-guessing my every decision. I'd like ...
6
votes
3answers
5k views

Self populating view models

So I have a view model (asp.net mcv 3 app) that when instantiated with a particular parameter, populates it's properties via a couple of calls to a web service in it's constructor. ...
2
votes
2answers
654 views

Return custom assembly attribute variables

I have a custom attribute in my assembly called SemverAttribute, and I have a helper class called AppInfo that has a function to return a number called the Semver number. It accepts an id of null-6. ...
4
votes
1answer
1k views

Using static management class to control db transactions through an EF6

I have the class below to manage my specific implementation of a membership system using entity framework 6.1 Is the use of static access correct in this case? as far as I understood that EF context ...
3
votes
2answers
4k views

Old-way of asynchronous programming in ASP.NET MVC 3

On ASP.NET MVC, I try to write an async Controller action with the old asynchronous programming model (actually, it is the current one, new one is still a CTP). Here, I am trying to run 4 operations ...
3
votes
1answer
6k views

nTier architecture for an MVC application

I am endeavoring to build my first non-trivial web application and so I'd like to confirm a couple of design decisions. I have three tiers as follows: UI (my MVC project) Business Logic (separate ...
4
votes
3answers
352 views

Is this a proper use of a services project and an ASP.NET MVC controller? [closed]

I'm a little unsure as to what code belongs in the services and what belongs in the controllers. Lets say I'm creating a website that requires a fine grained level of permissions (e.g. a user has ...
20
votes
1answer
40k views

Correct usage of EF's DBContext in ASP.NET MVC application with Castle Windsor

I am trying to use Entity Framework as simple as posible. Use UnitOfWork and Repository patterns seems to be overkill because whole web application will be pretty straightforward. I came with this ...
3
votes
2answers
2k views

ASP.NET MVC using Repository pattern - code review

I am just trying to use ASP.NET MVC using repository pattern. Could somebody see If I am doing something wrong here. Model - Contains the model ...
6
votes
2answers
883 views

Is this user input field secure?

I'm pretty new to asp and c# and I have a couple of concerns with the security of the code I have written (shown below). Basically all it does is allow you to enter a quantity before you add the item ...
7
votes
2answers
3k views

ASP.NET MVC using an N-Tier Model and DDD

Any comments are welcome. However I'd like to call specific attention to my... interpretation of the N-Tier application architecture and how I'm consuming data. Note that the namespacing and inline ...