Hot answers tagged asp.net-mvc
19
I have developed real applications with both Rails and ASP.NET MVC, but this answer comes with a significant caveat: I learned and developed with pre-version 2 Rails, so it is entirely possible that I am vastly out-of-date with my Rails knowledge.
That being said, I don't think that there is anything that can be done with one but not the other. Given any ...
19
Actually there is a push back in the .NET world against these very things you mentioned. In the first example you gave however, the routing engine is given a convention for mapping the default route. The very fact that the routes are dynamic make it nigh impossible to use a static configuration.
You also mention XAML/WPF, both of which were under ...
19
You should try to meet two goals: Uniqueness, and usefulness.
Using a GUID guarantees uniqueness, but one day the files may become detached from their original source, and then you will be in trouble.
My typical solution is to embed crucial information into the filename, such as the userID (if it belongs to a user) or the date and time uploaded (if this is ...
18
I recently switched from using in-line SQL queries to using EF and here's what I've found:
Pros
Much faster to build the DAL (love not writing the SQL queries!)
Much easier to maintain
No longer need to remember to parse my input before building an in-line sql statement, which means less chance of a SQL injection attack (of course, it's still possible ...
16
Here is a basic syntax comparison
<!-- Razor -->
@foreach(var item in View.List) {
<span>@item.Name</span><br/>
}
<!-- XSLT -->
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:apply-templates/>
...
15
It could have been done in a variety of languages and frameworks. As I recall SO and its sites are done in MVC not just vanilla ASP.Net. I'm sure it's as much an extension of the collective developers' combined expertise as much as it is a technology choice. If you really got down to it, this site could have been done using raw html, javascript and lisp as ...
15
I don't see any reason for Repository pattern to NOT work with Entity Framework. Repository pattern is an abstraction layer you put on your data access layer. Your data access layer can be anything from pure ADO.NET stored procedures to Entity Framework or an XML file.
In large systems, where you have data coming from different sources (database/ XML /Web ...
14
Generally, you want your Controllers to do only a few things:
Handle the incoming request
Delegate the processing to some business object
Pass the result of the business processing to the appropriate view for rendering
There shouldn't be any data access or complex business logic in the controller.
[In the simplest of apps, you can probably get away ...
13
How can open source projects be successful without documentation about their design or architecture?
Most successful open source projects became successful because first and foremost, the program was impressive or did something no other program could do at the time. That doesn't necessarily mean the source is well-documented, since the programmers which began the project to begin with know the code well enough to not need it. It's an unfortunate reality ...
12
I'll share the way I ended up doing this, that was part of the original question.
First, the problems I encountered:
With customErrors on (i.e. in production) The global HandleError attribute swallows exceptions and renders your error view, but then you can't log it with an addon tool like elmah, since elmah never sees it. You could log it in your view I ...
12
Displaying the key is totally optional, but it isn't a security issue even if you do. You need to check if the user has access, always. That is your job, not the framework's.
But you don't have to use a numeric id. I like to do something like the content type and title in the url:
/news/title-of-article
/reservations/description-of-hotel-and-reservation
...
10
Here's one take from Ayende Rahien: Architecting in the pit of doom: The evils of the repository abstraction layer
I'm not sure yet whether I agree with his conclusion. It's a catch-22 - on the one hand, if I wrap my EF Context in type-specific repositories with query-specific data retrieval methods, I am actually able to unit test my code (sort of), which ...
9
its a great question, the examples I found to be extremely helpful are
I have posted an answer before (here), which is relevant for this question
in short
Using Open Source:
http://www.sharparchitecture.net/ - an architecture using NH and looking to use EF later
http://whiteboardchat.codeplex.com/ - look at the report too
...
9
This is a very subjective question in some respects, but I will attempt to answer the parts that can be reasonably answered.
Isn't the performance of MVC a bit slow?
No. Of course, it is possible through a really poor implementation of the pattern to cause it to perform poorly (but that is true of anything and everything), but the pattern itself is not ...
9
In your example, I like the FullName getter (for all the reasons you have given) but I do not like the FormattedPhoneNumber getter. The reason is: it's probably not that easy (once you have international phone numbers etc.) and if you place the logic for formating phone numbers in a method of Member, chances are you will need to refactor (or copy-paste ...
9
How can open source projects be successful without documentation about their design or architecture?
why an open source project can become successful if new-comer developer have no architectural/design document to read?
The assumption is invariably made that you know what you're doing and have a reasonably intimate understanding of what you're going (and expecting) to see.
If you look into the PHP code of the Symfony framework, for instance, you're ...
9
How can open source projects be successful without documentation about their design or architecture?
Because open source developers are usually talented and also choose project in their expertise area, they already have "documentation" within their skulls. With little exaggeration thorough documentation is needed only if you lack any of those :o)
To be honest, I don't really read "documentation" when facing unknown codebase. A quick introduction, maybe a ...
9
You don't need to learn ASP.NET Web Forms to learn ASP.NET MVC, and none of the tutorials will require that of you. You will, however, need to learn C#, SQL and HTML. You also need these same skills to write programs using ASP.NET Web Forms.
The ASP.NET MVC site is probably the shortest possible path for learning ASP.NET MVC for a beginner. If you follow ...
9
Using TDD and automatic unit testing doesn't imply that the final tests will cover all cases and code will be absolutely correct and bug-free. It is easy not to see some complex use-cases and possible bug.
TDD on the other hand makes it easier to introduce changes for those not-thought-before cases. Simply repeat TDD as if you were developing:
Write new ...
9
Why do you have this understanding? Both encodings [UTF-8 and UTF-16] can encode all unicode characters by the definition of them being unicode encodings.
Anyway, UTF-8 is more optimal for storage and transmission than UTF-16 in your case. Majority of your characters in the files will not be in Chinese but in markup/js syntax. UTF-8 uses 1 byte for those ...
8
POCO stands for plain old c# objects. It comes from the java equivalent POJO. It's just a hip name to show the world that not everything has to be a derived class. POCOs are not necessarily DTOs, they can be full blown objects with behavior and state and clild POCOs, while DTOs only have state.
Now about your domain - if as you say you are trying to do ...
8
Stateless means that HTTP doesn't have built in support for states. i.e. you can't store if a user have logged in or done something else.
The most common solution is to use sessions to overcome that problem. This means that you have to be able to include a session identifier in each response or request. It's either done by creating a session cookie or by ...
8
Entity Framework is a productivity tool. Unless you have a good reason not to (E.G. you are on SQL 2000 or have no time to ramp up on the technology), then use the best tools at your disposal.
That being said, I find the concept of Entities to translate very well to the MVC pattern's Model. While having a 1:1 relationship with Models and tables is a bad ...
8
A typical multi-tier application looks like this:
In an MVC application, the data tier and logic tier reside in the Model, while the presentation tier resides in the View. In between the Model and the View, the Controller provides a switchyard, routing web requests and responses to the appropriate methods, views and model logic.
Within the Model, you ...
7
I have been making my living off of .NET/C# exclusively since 2002, and I am an unapologetic fan of Microsoft's development tools, frameworks and OS's. I have also delved deeply into RoR, having used it to build a substantial (though under-marketed and under-used) web application (mykidslibrary.com).
I learned RoR not with the objective of getting away from ...
7
I can think of two methods that could work:
The "Right" way: put together a business case, and convince your manager -- if you can suggest financial or time/speed (which is also financial) benefits, like "easier to maintain due to better separation of concerns, so support turnaround time will be quicker", or "newer technology, so it will have a longer ...
7
Right off the bat you can download and try out The BeerHouse CMS and e-comm project from CodePlex. This is an asp.net MVC based application with e-commerce areas setup and should be able to be wired up to most payment gateways. In addition, it's been around for a while, and has two books which walk through most of the code, design considerations, and it's ...
7
None of the concerns you identified seem particularly relevant for choosing a hosting company, especially traffic rank. Hosting companies host websites that gain traffic; they don't provide content themselves. Consequently, I wouldn't expect them to rank particularly high in a Google or Alexa search.
I would be more concerned with things like:
What ...
7
A lot of people these days (based purely on my professional exposure) are now using ORM tools for the benefits they provide.
Benefits include:
Lazy loading
Multiple database targets
For some frameworks, use of LINQ to select records (i.e. Linq-to-SQL, Entity Framework)
Not having to change multiple queries when you add a field
The primary negative as ...
Only top voted, non community-wiki answers of a minimum length are eligible