Tag Info

Hot answers tagged

115

I developed ASP .Net WebForms applications for 3 years, and after one day of doing an MVC tutorial I was sold. MVC is almost ALWAYS the better solution. Why? The page lifecylce is simpler and more efficient There is no such thing as controls besides html controls. You don't need to debug your output to see what ASP .Net is generating. ViewModels give you ...


86

The single best reason to not use the repository pattern with Entity Framework? Entity Framework already implements a repository pattern. DbContext is your UoW (Unit of Work) and each DbSet is the repository. Implementing another layer on top of this is not only redundant, but makes maintenance harder. People follow patterns without realizing the purpose of ...


72

Webforms vs. MVC seems to be a hot topic right now. Everyone I know touts MVC to be the next great thing. From my slight dabblings in it, it seems ok, but no I don't think it will be the end of webforms. My reasoning, and the reasoning as to why webforms would be chosen over MVC, has more to do with a business perspective rather than what one is better ...


60

You are conflating the Razor syntax with separation of concerns. Separation of concerns has to do with how you structure your code. Being able to use C# in views doesn't prevent that. It has nothing to do with separation of concerns as such. Sure, you can structure the code in your view to not comply with separation of concerns, but what about C# code ...


58

I emailed Scott Guthrie, an MVC expert at Microsoft. And probably the most qualified man to answer this question. He was kind enough to reply: "Different customers look for different programming approaches, and a lot love WebForms and think it is great. Others love MVC and think it is great. That is why we are investing in both. " So, to me ...


40

Stateless - There's no memory (state) that's maintained by the program Stateful - The program has a memory (state) To illustrate the concept of state I'll define a function which is stateful and one which is stateless Stateless //The state is derived by what is passed into the function function int addOne(int number) { return number + 1; } ...


37

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


36

I don't see any reason for the 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 ...


33

Rather than directly answer the question, my response questions the assumption made in the question. That is, the assumption that Razor was built for MVC is incorrect. I work at Microsoft on the ASP.NET team and have first-hand knowledge of this. Razor did not start out as a view engine for MVC. It was created for ASP.NET Web Pages, which is probably as far ...


32

I am a complete and total convert to ASP.NET MVC and have not looked back, that said I do still have to maintain several very large WebForms apps. Here's my take on it: WebForms Use these when you have some serious heavy lifting to do with grids. The grid controls are really very nice when you have a simple dataset that fits nicely in a tabular format and ...


32

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


29

stateless means there is no memory of the past. Every transaction is performed as if it were being done for the very first time. statefull means that there is memory of the past. Previous transactions are remembered and may affect the current transaction.


25

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


23

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


22

This answer is going to get downvoted into oblivion but, on the whole I see WebForms as being for cargo-cult programmers, while MVC is the technology of choice for more seasoned developers who understand the importance of simplicity & maintainability.


21

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


21

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


21

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


18

I HAVE successfully used XSLT as a web presentation tier... in 1999. In the last 12 years, much better options have come along. Do yourself a big favor, and use Razor. It's a pleasure.


18

private void Demo() { // Do something, given that the result doesn't matter. } public void Do() { Task.Factory.StartNew(this.Demo); // The following line will be executed without waiting for the result. DoSomethingElse(); } Note that starting a method without caring about the result or about exceptions it can throw is risky. If an ...


17

Here is a basic syntax comparison Razor @foreach(var item in View.List) { <span>@item.Name</span><br/> } XSLT <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="item"> <xsl:for-each select="name"> <xsl:value-of ...


17

Process that people should be doing on a job as a new hire Initially look at the code Small bug fixes Bigger bug fixes Feature Requests - Adding something to an existing piece of the puzzle New things - Creating something from nothing Rushing a green developer with no domain experience too far too fast will cause way too many problems. You're going to ...


17

Is there maybe a more stripped down starting point I should use if the VS template is adding a lot of stuff I don't need? These VS templates are good to trim down initial setup and learning curve in the beginning, however you would need to customize them for your real project needs. For example, on this site http://www.reviewstoshare.com, my friend ...


17

This sounds suspiciously like an inner platform. Here are the potential problems: You'll be writing queries that query the database for what information to query (metaqueries) first, rather than queries that simply retrieve the needed information. You'll be subverting the role of the database, which already provides metadata capabilities such as rows, ...


16

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


16

Presentation logic comprises the logic and calculations that are needed to present the business data in the right way for a particular view. For complex graphical views, this can be quite complex calculations (for example, calculating the size of each pie slice and the positioning of the labels for a pie chart), but the main characteristic is that it only ...


15

My experience: Wrote CakePHP projects for one year. Completed a medium sized Webforms project over six months. Worked on a Windows Forms project for three years. After that experience, I tried writing another app using webforms, and got frustrated after struggling for about a day with how webforms attempts to shield the developer from the reality that ...


15

This is a stale question with a lot of answers but none had the answer I would have expected to be listed. The short answer is: Use ASP.NET MVC if you intend to properly build a web application with modern programming conventions and industry embraced patterns for the ASP.NET platform. On the down side you will be expected to know how HTML and ...


15

In my applications I have always separated things out, with different models for the database (Entity Framework) and MVC. I have separated these out into different projects too: Example.Entities - contains my entities for EF and the DB context for accessing them. Example.Models - contains MVC models. Example.Web - web application. Depends on both ...



Only top voted, non community-wiki answers of a minimum length are eligible