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

learn more… | top users | synonyms

4
votes
1answer
49 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 ...
0
votes
0answers
27 views

Adding viewstate based property and implication in future converstion to mvc in asp.net forms project

Suppostedly 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
1answer
1k 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 ...
1
vote
1answer
2k 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: ...
1
vote
2answers
661 views

MVC : Does code to save data is session or cache belongs 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 ...
3
votes
3answers
292 views

How to refactor this property's code?

I have a view model with properties that represent years and months: ...
1
vote
0answers
219 views

MembershipProvider with Entity Framework and IoC in asp.net MVC3

I am using Castle Windsor as my IoC and I registered it as DependencyResolver to let MVC framework know about it. With Entity Framework I have this DbContext: ...
1
vote
0answers
65 views

ASP.NET MVC - Help needed to Improve the code for Drop-Down Box?

I have created the below drop-down to populate a list of cities. All works fine, but I would like to know the better ways of doing this please. Also, please let me know if it is possible to create ...
1
vote
2answers
147 views

Is my code (clean code separation) is correct?

The code below is an approach of clean code separation, but I am confused if it is a right approach or wrong. Please suggest me. ...
7
votes
1answer
3k 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
185 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: 1: Get ...
6
votes
2answers
256 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 ...
2
votes
2answers
3k views

Wrapper for jquery ajax to ensure redirects occur on clientside

Recently I had the need to make some ajax calls within a MVC 3.0 with Razor and jQuery application. After a bit of trial and error and refactoring it was discovered that a number of different needs ...
3
votes
3answers
5k views

Search and Filter in MVC3 Razor I am using Linq, is there a better way to do this

Heres my Code and it works fine. I just dont like all the If else, what If I keep adding field to filter, its going to get messy. Ps: I am not using EF and cannot on this. Thanks. CONTROLLER CODE ...
3
votes
3answers
120 views

What standard should I use for the naming of my MVC controller services?

I have the following: ...
3
votes
1answer
1k views

Creating a list of pairs after splitting the string containing all of the sets

I am working on asp.net/MVC and I need to read a value from my web.config file. Splitting the list into multiple keys is not an option. ...
3
votes
1answer
889 views

Asp.net MVC login method

I wrote this login method: ...
3
votes
3answers
643 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. ...
5
votes
2answers
454 views

Is there a better way of writing this action method using Linq?

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: ...
10
votes
3answers
2k views

What's “The Right Way” to Separate 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: ...
5
votes
2answers
1k 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 ...
1
vote
0answers
281 views

Amazon s3 pass through controller [closed]

Some background, I am building a website that uses amazon s3 to host its image (and other) files. I required that images displayed on the website look like they come from my site and not from amazon ...
1
vote
2answers
706 views

Many to many crud using entity framework 4.1

My view submits data to the controller using Json objects which contains child objects.It allows users to add/remove/modify the relationship with child entities(authors,categories,LIbraryBookCopy). ...
5
votes
1answer
470 views

This LINQ Model Query seems extremely inefficient

I'm new to LINQ, but I have some background in T-SQL. I know there are probably 100 different ways to design a T-SQL statement that would run this much more efficiently, but I'm not sure how I would ...
6
votes
0answers
1k views

Fluent LinkedIn REST API client interface design

There is a handful of LinkedIn clients written in C# on the NuGet package library, but afaict most only do authentication via LinkedIn. I found a couple which offer a linkedin rest api interface. Of ...
2
votes
0answers
483 views

Custom Authentication Attribute, seems to work fine but is there any drawbacks?

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 ...
1
vote
1answer
252 views

Fluent NHibernate, Getting or Creating a new `Tag`

Edit The rest of my code utilises the Command/Query seperation pattern. I'll probably move this out into a command and a query but for now I've written this directly in my MVC controller for brevity. ...
34
votes
4answers
26k 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 ...
4
votes
2answers
4k views

Passing an array of values in Url.Action

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

my code is ugly

I have a method which load data from a remote app(send tcp request and parse response). Now, I have simple class for send tcp request: ...
2
votes
2answers
185 views

Can someone tell me if I'm barking up the wrong tree with this ASP.Net MVC/Entity Framework pattern?

So 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 descision. I'd like ...
0
votes
1answer
394 views

Is there a prettier or more performant way to create an MVC Pager Helper?

I've got this MVC Pager Helper and it's working exactly as expected. I'm wondering if there's a prettier or more performant way to build this out? Also, I know that the StringBuilder might not be the ...
2
votes
2answers
337 views

How can I avoid all this code duplication?

As you can see I have to populate the ViewModel with the List of Tags so that the dropdown can have all the options for the user to select. And I have to do this 2 times for the Create Action and 2 ...
3
votes
1answer
2k 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 ...
3
votes
0answers
625 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 ...
1
vote
3answers
90 views

Improving readability and logic on “re-indexing” method

This is a method which takes an input of a "page" object, which includes SortOrder. It then fetches the existing page items from a database and attempts to re-index. I don't think this is at all ...
2
votes
0answers
469 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 ...
4
votes
0answers
157 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: ...
7
votes
1answer
620 views

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

(I posed this in SO, but since it's a kind of code-review question, it's now here too) 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 ...
4
votes
1answer
2k views

ASP.NET MVC models that can be validated without using attributes

The model looks like this, with no attributes: ...
4
votes
1answer
459 views

LINQ generating chart

I'm generating a table to use on jQuery visualize plugin and generate a chart. The code is pretty good, but maybe there is a way to improve it. Maybe do more work on the LINQ query and less stuff on ...
2
votes
3answers
199 views

ASP.NET MVC Html.XXFor OK to discard lambda argument and just use Model directly?

I find it a bit odd in ASP.NET MVC that the Html helper extensions, like Html.EditorFor, take a ...
3
votes
1answer
3k 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 ...
2
votes
0answers
677 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 ...
2
votes
1answer
937 views

Using WIF with ASP MVC 3 for authorization

What can be the best way to implement custom authorization attribute in MVC 3 using claims? For example we have claims: ...
3
votes
2answers
2k 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 ...
0
votes
1answer
126 views

Is there any javascript pitfalls with this approach that I might be missing?

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 the model. One of the form's ...
2
votes
1answer
268 views

Refactoring of my code

I'm new in ASP.NET MVC (using MVC 3). Could you inspect (refactoring) my code, to advise, or anything else? Maybe something can be rewritten in a more compact. A few details about site: on main ...
7
votes
1answer
15k views

MVC Custom Authentication, Authorization, and Roles Implementation

Bear with me as I provide details for the issue... I've got an MVC site, using FormsAuthentication and custom service classes for Authentication, Authorization, ...
7
votes
1answer
8k views

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

I'm trying to build friendly URLs like this /post/1/my-first-post. I started out with building my links like this: ...