Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

11.14.2013

Visual Studio using old app.config value or setting

Once in a blue moon, I will run into a problem with Visual Studio 2012 where the App.config for a console application is getting cached somewhere and there's no way to release it.  So the App.config is stuck with old values which aren't correct for the application today.  It's happened maybe twice this year to me.

The App.config in my solution shows the correct values.  The one that's been put in the output directories for Debug and Release both look good, but my quick little console application is pulling ghost values from an App.config from last week. I've tried building, rebuilding, and finally, all to no avail.

The only thing I could think of to fix this ( which did work ) was:

  • Copying the contents of the App.config file from within Visual Studio
  • then delete the file from within Visual Studio
  • Then re-add the config file
  • Then paste in the contents.
  • Rebuild and run.
I'm going to chalk this one up to ghosts in the machine.  

9.18.2012

ASP.NET MVC Model binding in PHP?

I've been working a lot this year with ASP.NET MVC 3 and C#.  One of the things I really like about these technologies is the model binding.  Let's say I have a data model called "User", a plain old C# class like this:



I can set that as a model for my view to use in the "Edit" controller like so:




And then I have "User" as the data model in my view.  Here's what's awesome about it, let's say I need to accept edits of the user account, maybe they can fix their first or last name.  I can pass that same User model from the previous page via a form into an Edit method that accepts that data model.  I don't have to muck about with assigning the Request variables ( POST / GET ) to an object.  All that is handled for me.



The ASP.NET MVC model binding will attempt to bind your model in these scenarios:

- If you have a form element on the page with an idenitical name to a property in the model
- If the url contains a key value pair from your routing that is identical to a property in the model
- If any REQUEST element has a name that is identical to a property in the model
- Otherwise, that property of the model will remain null

Plus, the ASP.NET MVC model binding will let you turn on/off model binding for various properties of the model.

PHP, or rightly, the many PHP frameworks really need to implement something like this.  A few perform some pieces of this concept but I'm not aware of any that currently serve up the whole enchilada.  What do you think?