Hot answers tagged

191

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


44

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


40

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


37

Welcome to one of the hardest problems in non-computational programming - properly representing dates and times to end users. Realistically, timestamps should be stored in a fixed single representation regardless of how they will be interpreted, because no matter how hard you try, you will always have ambiguous cases, and you can't resolve them without a ...


36

Generic repository is even useless (and IMHO also bad) for Entity Framework. It doesn't bring any additional value to what is already provided by IDbSet<T> (which is btw. generic repository). As you have already found the argument that generic repository can be replaced by implementation for other data access technology is pretty weak because it can ...


33

You're overestimating the importance of source code, and underestimating the importance of everything else in the value chain of selling software. Sure, a contractor might steal your source code. But what then? Will they be able to create a release, maintain the code further, contact your customers and sell them a knock-off for a lower price? Almost ...


30

This is not a direct answer to the question, more of an expansion on it. When you launch a new app I recommend logging everything the user does: log in, log out, scratches their a**, everything. If it's web-based, consider using heat maps so you know what their mouse was doing. When I was on the BravoX project at Xerox in the late 70's we recorded pixel-by-...


28

One reason is security - if (haha! when) a hacker gains access to your front-end webserver, he gets access to everything it has access to. If you've placed your middle tier in the web server, then he has access to everything it has - ie your DB, and next thing you know, he's just run "select * from users" on your DB and taken it away from offline password ...


26

The answer to this question is completely subjective. The length of time it takes a developer to come up to speed can depend on: the developer's level of knowledge and professional experience the level of complexity of the application(s) or the level of documentation for the same the ability of current application "experts" to onboard new developers. By "...


25

When you start a project and have a particular need, you have a choice: Either you implement your own solution from scratch, Or you use an existent library or framework. When implementing your own solution, you introduce several risks: The needs may evolve, requiring you to constantly write more and more code. Ultimately, the code you've originally ...


23

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


22

Stop! You have a bigger problem than the readability. It looks like you don't understand how object initializers work. Let's create a disposable class which traces its execution: public class Demo : IDisposable { private string hello; public Demo() { Debug.WriteLine("The parameterless constructor was called."); } public Demo(...


22

.NET Framework is a VM, a JIT compiler, an object memory system consisting of a memory allocator and a garbage collector, a loader, a linker, and a runtime system (collectively called the Common Language Runtime (CLR)) which executes and supports a language called Microsoft Intermediate Language (MSIL). It is also a class library called the Base Class ...


21

At my current job I am the sole developer and when I started nobody had any knowledge of the code. I was given a codebase with 200k lines of code and told to implement new functionality against this codebase from day 1. It probably took a week before I was writing useful code and three months before I understood the codebase well enough to track down most ...


20

The most direct quote I've found is part of Scott Guthrie's announcement of the MVC 4 roadmap, back in 2012, (apparently offline but available via the Wayback Machine) which contains the following quote: Json.NET: We plan to use the community developed Json.NET serialization stack in our default JSON formatter in ASP.NET Web API. Json.NET provides the ...


19

This is like asking what the difference is between an apple and an apple core. These two architectures aren't replacements for one another. I think a more accurate view is that the 3-tier architecture augments MVC. The MVC Architecture Models: These represent "stuff" in your application. This layer has gotten a little fuzzy in recent years, as I will ...


19

Is CQRS a relatively complicated and costly pattern ? Yes. Is it over-engineering ? Absolutely not. In the original article where Martin Fowler talks about CQRS you can see a lot of warnings about not using CQRS where it's not applicable: Like any pattern, CQRS is useful in some places, but not in others. CQRS is a significant mental leap for all concerned, ...


17

It depends. But IMHO, it should take about a month to know your way around, and up to six months to be normally productive. An interesting exercise, if you have time, etc: Take a part of the application, and reprogram it in another language, if you know any. Or, try reading all of the source code that you can, and write down what it does. That should help ...


17

multipart/form-data is a construct created for HTML forms. As you've discovered the positive of multipart/form-data is the transfer size is closer to the size of the object being transferred--where in a text encoding of the object the size is inflated substantially. You can understand that internet bandwidth was a more valuable commodity than CPU cycles when ...


17

I think you're expecting too much of the pattern you're using. CQRS is specifically designed to address the difference in model between query and commands to the database, and MediatR is just in-process messaging library. CQRS doesn't claim to eliminate the need for business logic like you're expecting them to. CQRS is a pattern for data access, but your ...


16

ASP.NET Web API is a "non-opinionated" framework to build HTTP Service regardless of REST or RPC. It is Microsoft's best implementation of RFC 2616 (HTTP Spec). Certainly you can build your own API but ASP.NET Web API: Built based on the Russian Doll model which allows for lego-like modules to be added to the HTTP pipeline Makes HTTP first class citizen so ...


16

You do need them as the client can decide to allow javascript in their browsers. You also should consider those people who want to break your software. There are plenty of tools out there that can manufacture posts and submit them to your website without having used your front end. Client side validation is nice for the user, but the server should never ...


15

Refactoring or not, you should be using source control. It will save your bacon whether the team is one developer or one thousand. If you try to maintain two concurrent branches of development the current version and the mythically beautiful refactored version, you will never get the codebase refactored the way you want it. It makes far more sense to ...


15

You cannot check through a browser if the user have other software like Word installed. If that was possible it would be a huge security hole.


14

1740 minutes is 29 hours: Back when IIS 6 was being developed—which is the version that introduced application pools—a default needed to be set for the Regular Time Interval when application pools are automatically recycled. Wade suggested 29 hours for the simple reason that it’s the smallest prime number over 24. He wanted a staggered and ...


14

Not a whole lot. The people to program things, and the people to manage the infrastructure are a few orders of magnitude more expensive than any hosting cost issues you can run across. There are plenty of free "gems" -- check out nuget for .NET's version of that. Cloud-wise, both EC2 and Azure offer windows boxes so you aren't stuck owning hardware. The one ...


14

I would use the Html Agility Pack to assemble HTML and then write it out to a text file. A lot of man-hours went into making the Html Agility Pack robust and HTML-compliant HTML-friendly. I think it even includes a sample application that generates HTML. From the home page: Sample applications: Page fixing or generation. You can fix a page the way you want, ...


13

Use a database, thats what they are for. File storage has its place, but I wouldnt use it for this kind of scenario. Consider, for example, getting a list of blog posts containing a certain tag. Doing that with a database is trivial - likely just a single SQL statement. Doing it with files will involve a lot of file manipulation.


13

ASP.NET MVC applications are compiled. This means that you can't just upload the changed files, like you do with a PHP website, for example. This also means that when you'll start to update the site, current users will be thrown away (lose their sessions, for example). There is also much more to do than simply update the files: you have to handle: ...


13

You have two options. Create separate mywebsite.api and a mywebsite.app projects in your solution. Advantages Proper separation of concerns. You can deploy updates to your api and your front end independently. Architecture of sites can be changed independently (i.e. you can update your api to run on asp.net 5 without affecting the website) Cleaner ...


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