Category Archives: ASP.NET

In Case I Forget a Third Time: project.json config for referencing full .NET DLLs

I’ve been working with an ASP.NET 5 app that uses an EF6 module. The EF6 module is .Net 4.6.

When re-creating this from scratch, I keep making the same mistake which confounded me for hours the first time and only 15 minutes the second time. I like to think that the next time, I will remember how to do this in advance but decided I better write it down.

Here is the default project.json for a new ASP.NET 5 MVC app that does not have any identity infrastructure set. This was scaffolded directly by the ASP.NET 5 Web App template where I chose to have no authentication included. Also of note is that I’m using RC1.

  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true

  "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }

  "exclude": [
  "publishExclude": [
  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]


I need to add a reference to my .NET4.6 class library project called EF6Model. This is not an ASPNET5 project. No dnx. No dnu. Just straight .NET. My first instinct is to add it into the dependencies section after ““Microsoft.VisualStudio.Web.BrowserLink.Loader”. It does nothing but fail fail fail. Squiggly lines. Can’t build. Only help is “sort”.

The core of the problem is that the default scaffold specified that this would be for dnx451 and dnxcore50 frameworks. My assembly is not recognized by dnxcore50. In the dependencies section, I am saying that everything in here should work with both frameworks. That’s not true.

If I know I am never going to need the dnxcore50, I can just remove it from the frameworks section:

 "frameworks": {
    "dnx451": { }

Also, the default .Net version here is 4.51. My dll is 4.6 so I have to fix that, too.

 "frameworks": {
    "dnx46": { }  },

This change will required that you run dnu restore  — well at least I had to do that! Smile 

You can also specify the dependency directly in the framework section instead of the dependencies section ala:

 "frameworks": {
        "dnx46": {
            "dependencies": {
                "EF6Model": "1.0.0-*"

I like this because it explicitly tells me that EF6Model is special and is only supported by dnx46. As I evolve my app and possibly make changes to the dependencies or even the frameworks, I know that what’s in the dependencies section should be supported by any targeted framework, while the framework specific dependencies are very obvious.

Having written this down, I hope now that it is now in my brain and I won’t have to waste time wondering about those errors any more.

How I see Web API

Using OData in apps is so easy thanks to the RESTful API that lets us use HTTP directly & JSON results. But OData works directly against a data model with a limited set of operations and capabilities. You can do some customization but at some point you get beyond the point of data services.

So then it’s back to WCF Services where you can have oh so much control over the service but boy can it get complex, especially when you want to leverage various protocols in WS-* e.g., security, etc. And you have to speak the language of the service which is different from one service to the next.

I see Web API as potentially the best of both worlds. I get to have control of the logic in my service, but I can consume it very easily with HTTP.

Value add to my education and this post via Glenn Block: “Definitely a big value prop for Web API is allowing multiple devices to consume the same applications while at the same time taking advantage of client capabilities.”




MSDN Guidance on ASP.NET MVC vs WebForms and its Impact on my EF + ASP.NET Work

Last year at the fall 2008 DevConnections conference, I was very happy to hear Scott Guthrie providing a clear message about web forms vs. MVC in ASP.NET 4.0.

Now, I am seeing something that is new for MSDN Documentation, not only similar clarity but actual guidance on when Microsoft suggests to use one over the other.

You’ll find this in two places.

First, in the ASP.NET MVC Overview topic. In this document, their is a list of advantages of MVC and a list of advantages of web forms apps.

Next, in the topic titled Compatibility of ASP.NET Web Forms and ASP.NET MVC, there is a short list of strengths of web forms and another of the strengths of MVC. Following this are short lists of features that are compatible with MVC and then those that are incompatible with MVC.

Key from the overview doc:

Line of Business web apps

  • Web Forms “preserves state over HTTP, which benefits line-of-business Web application development.”

Web Forms for RAD and MVC for granular control??

  • Web Forms “works well for small teams of Web developers and designers who want to take advantage of the large number of components available for rapid application development.”
  • Web Forms “in general … is less complex for application development".”
  • MVC is for “large teams of developers and for Web designers who need a high degree of control over the application behavior.

Test Driven Development

  • MVC “provides better support for test-driven development (TDD).”

The bottom line?

There’s a way of reading the documentation that might cause you to summarize that Web Forms is for RAD development and MVC is for serious application development. Does that mean the line of business apps do not belong on the web because they require us to use session state and any web developer in his/her right mind would not want to incorporate session state in their applications? Well, the problems that pop up when you start considering session state on distributed servers suggests that the answer to this question is “yes”. But ASP.NET developers never really had an option before.

Remember that ASP.NET was created so that windows developers could write web apps, and that’s why things like session state and view state are so critical in web forms. They are potentially cumbersome to deal with and easily misused.

MVC goes back to a more purist form of web development which is state-less. But a stateless environment doesn’t lend itself well to having large units of work which we have gotten used to in LOB apps.

On the other hand, even the documentation says that you will have a lot more work ahead of you if you want to work with MVC. First of all, there’s a major paradigm shift from web forms, especially for those who don’t come from a web background prior to ASP.NET.

Where does this leave me?

This leaves me much more curious about MVC and thinking that I may shift my focus of attempting to design serious web app that use Entity Framework from web forms to MVC. It also leaves me nervous since it also might mean a major last minute change to one of my DevConnections presentations this week. It will be hard because leveraging MVC to demo another technology depends on the audience having a general understanding of MVC which is not something that I can expect at all. Now if my session were 4 or 5 hours long, it would be a different story.

ASP.NET 4.0 Dynamic Data and Many to Many Entity Framework Entities

Even though I’m a much bigger fan of distributed apps than using UI bound data binding, it’s still important for me to know how these various tools work – especially since I need to write about them in my updated E.F. book. 😉

I did not play much with Dynamic Data controls in VS2008 and just made a cool discovery in VS2010 Beta 2. This may not even be new, but as I’m sitting 30,000+ feet over the Atlantic ocean, I don’t have access to VS2008 at the moment to check.

I have a database that has a join table between two other tables.


Because the join table has only the keys of the tables that it is joining (and no other fields such as “AddedDate”, etc.), the EDM Wizard is able to create a many to many relationship between them and hide the join table. (If there were additional fields in the database table, then there would be a join entity in the model.)


I just created a new Dynamic Data website using all of the defaults except for one. Rather than automatically using every entity in the model, I selected specific entities to include in the site. Other than this, I have done absolutely no customization.

When I ran the app and opened up the People page, I was surprised to see the names of the individual beers listed in the Beer column.


But I was even more surprised when I chose to Edit the person and saw how brilliantly the Dynamic Data templates handled the Entity Data Model’s many to many relationship.


I am going to have to stop turning my nose up at these tools, though I may still have to pinch my nose for Mr. lePieu and his choice of beers. (Better get some Magic Hat onto that list!)

For RAD website development, this is pretty impressive stuff!

MVC with Visual Basic video series

Bill Burrows has created a series of videos on MVC and is now working on a new series based on Scott Guthrie’s MVC tutorial posts (which are all in C#) but using VB instead. I was surprised to find a pointer to my recent MVC post as a “rare example” of MVC with VB (and it’s only one little post so I found that to be sad) so I’m happy Bill is doing these. It gives a leg up to VB developers who find it hard to try to learn something that is VERY new and convert the C# syntax in their brain at the same time.

Here’s the list of topics covered

  An Overview of the MVC Pattern
  Setting up the MVC Preview Environment
  URL Routing
  Setting up New Pages
  MVC Controller Actions 
  Creating HTML in Views 
  MVC – Putting it all together

Thanks to Beth for the heads up.

MIX08 Sneak Preview: The MVC tools

Remember how I recommended subscribing to the WebDevTools blog only a few weeks ago? (grin) Well, it continues to pay off!

Vishal Joshi has written a blog post about the tools for building MVC that will be previewed at MIX. Usually these goodies are shown first at MIX and then in blog posts.

Tooling Features Overview of ASP.NET MVC Framework for MIX 2008 shows some of the improvements made to the tools for creating MVC apps and more handily creating unit tests for them.


ASP.NET 3.5 Extensions enables Page View history with AJAX

One of the drawbacks with the partial postbacks in AJAX is that you can’t go forward or back in your web browser to different states of the page created by the partial postbacks. Nor can you create a shortcut to one of the views.

The ASP.NET 3.5 Extensions has functionality in there to enable these scenarios. It’s pretty simple to pull off thanks to the new tools.

Jonathan Carter has a great post on how to use this. It’s just #1 of more to come so keep tuned. Jonathan is a new to Microsoft’s Visual Studio Developer Platform and Evangelism team with the dream job of writing and speaking about all the cool things you can do in VS. You can tell by his post that he will be a great resource for us to learn new features.

ASP.NET Perf and Optimization lessons from Jeff McWherter

At VTdotNET’s last meeting, we were happy to have Jeff McWherter share with us his hard-earned lessons about improving performance in apps. Jeff spends a lot of time dealing with this in his job and it was very obvious that he wasn’t just sharing something he read about, but his very adept experience.

He started out by posing what may seem a redundant question, but is a really good way of getting people to focus on the issues. He asked for someone to explain the difference between web site performance and web site scalability.

These were the two topics he focused on as he delved into a number of performance bottlenecks as well as issues which prevent websites from being able to scale out. Jeff used a variety of performance measurement tools in the process which was very educational. Sure beats waiting for the server to come to it’s knees as an indication that some changes might need to be made! Then of course he showed us lots of ways, some very simple, some more complex, to solve the problems displayed by the tools.

Often people focus on their specific code and don’t consider out of scope processes that may be causing the problems such as a database query or a file download. I was happy that he made sure people were aware of SQLProfiler!

One of the tips that really hit home for me, because I was dealing with this problem, was if you have file download/upload functions in your application, split those off to another process, whether you can do that on another server or just in another app on your web server (e.g a web service). It’s not just the time involved (which can be helped also by doing this asynchronously) but the resources involved. If multiple people are uploading or downloading at the same time, this could really pose a problem.

In these days where many of us are scrambling to learn the new technologies that are coming down the pipe, it is a huge benefit to have someone show us how to get more out of the tools that we are working with today with lessons that will apply to the tools of the future.

The day after the meeting, Jeff and his wife (who had spent a fun few days with us at our house) headed off to Smuggler’s Notch to do some ice climbing and then were going to be on vacation for a while after that visiting friends around the Northeast.

I think he’s back in Michigan now, so I’ll be sure to get his list of resources from him and up on the VTdotNET site.