You are currently browsing the tag archive for the ‘ASP.NET MVC’ tag.

All my main development machines are now running Visual Studio 2012.  I have a few new projects in VS2012 and have begun updating my old projects to it as well.  I ran into an annoying issue today that I need to post.

My Blog by Email site was built using VS2010 and ASP.NET MVC 3.  My new machine, which I am working on right now, is running Windows 8 and VS2012.  Recently a new user started using the site and discovered a few bugs I needed to get fixed.  I cloned the repo from Bitbucket and opened the solution in VS2012.

My first tip-off that there was an issue is when the Migration Report displayed 7 errors all on the _bin_deployableAssemblies\ folder.

BlogByEmail\_bin_deployableAssemblies\Microsoft.Web.Infrastructure.dll: Failed to backup file as C:\vsp2k12\BlogByEmail\Backup\BlogByEmail\_bin_deployableAssemblies\Microsoft.Web.Infrastructure.dll 
BlogByEmail\_bin_deployableAssemblies\System.Web.WebPages.Razor.dll: Failed to backup file as C:\vsp2k12\BlogByEmail\Backup\BlogByEmail\_bin_deployableAssemblies\System.Web.WebPages.Razor.dll  (... Plus 5 more files)

My second is when I went to run the project and the build failed for the same 7 files.

If you recall the _bin_deployeableAssemblies folder is used to aid in bin deploying MVC 3 applications to [shared] hosts which don’t have ASP.NET MVC 3 loaded.  You can read more about it here [].

It turns out this isn’t required in VS2012 as I found here :

Starting with MVC 3 Tools Update we are now using Nuget package references, which means that your project is automatically bin-deployable. Since the tooling gesture is no longer necessary it was removed from VS 11.

The fix here is really simple.  Remove the files and _bin_deployableAssemblies folder from your project.  Everything should compile just fine.

Now the one part I have not figured out is where or how we get the files that used to be in _bin_deployableAssemblies.  I don’t see them in the bin folder as I assumed they would be.  I will need to do some test deployments at my host, Arvixe (I think they didn’t have MVC 3 loaded).  Add a comment below if you h ave some knowledge around this.

I just took the long silly way around to return a json result to  a page.  I kept trying to send a json string back as just that, a string and it just wouldn’t work.  Whenever JavaScript received the string it didn’t know what to do with it, except treat it as a string of course.  I banged my head against this one for too many hours.  Though my persistence payed off.

As the night got later (I think it’s 03:00 about now) I decided to figure out how others are returning json object from ASP.NET MVC.  It isn’t as simple as it should be, but not too difficult.  The biggest issue, as with much in MVC land is the huge lack of documentation.  So looking up something like JsonResult, yields a pretty useless help page.  So more time had to go into discovering on how to actually use this cool new result type.

It turns out you can set up and action with a return type of JsonResult (it’s usually ActionResult) and have that action return a json object.  I am not even going to pretend I can do this from other objects like (from James Newton-King).  I am using this to return a model as json which populates my form with on-demand instructions.  This library rocks, but I digress.

The basic structure I used is a dictionary object

public JsonResult MyAction()
  Dictionary<string, string> dict = new Dictionary<string, string>();
  dict.Add("keya", "valuea");
  dict.Add("keyb", "valueb");
  return Json(dict);

That’s pretty much it in a nutshell.  Json() is a new web helper in MVC3.  You can find it at System.Web.Helpers.

I saw one example where you can build an object on the fly, but I couldn’t get it to work.  It basically looks like this:

return Json(new {keya = valuea, keyb = valueb};

The dictionary generic works for now.  If you know of a better way, please let me know.

While working on Blog by Email ( I came across the necessity to create my own HTML helper class.  For those who don’t know helper classes “…reduce the amount of tedious typing of HTML tags that you must perform to create a standard HTML page.”

The registration request form on the site was getting hit pretty hard by spam bots and I was getting tired of cleaning up the mess, so I decided to add a captcha.

ReCaptcha is what I decided on and started down the rabbit hole.  First of all there was only ASP.NET examples.  Since I was writing this in ASP.NET MVC, I wanted to use a more, “MVC” approach to it.  I came across an post on named Using ReCaptcha with Asp.Net MVC.  The post covered exactly everything I need, what it was missing is details around its steps, specifically Step 5 – Create a Html Helper to build and render the Captcha control. It shows the current code and nothing else:

public static string GenerateCaptcha( this HtmlHelper helper )
  var captchaControl = new Recaptcha.RecaptchaControl
      ID = "recaptcha",
      Theme = "blackglass",
      PublicKey = -- Put Public Key Here --,
      PrivateKey = -- Put Private Key Here --
  var htmlWriter = new HtmlTextWriter( new StringWriter() );
  return htmlWriter.InnerWriter.ToString();

My first thought, is cool, I can just add an HTML helper to the view to generate the captcha, this is a good approach.

First stumble, that is a method, that needs to go into a class–what class should it go in to?

No problem, I’ll just look up creating helper methods.  That was an easy search which rendered an ASP.Net site page, Creating Custom HTML Helpers.  Great, now I have my examples.  I matched it to an extension method; okay, I get that, I have used those before.  I learned the syntax and added it to my site.

It doesn’t come up in Inteli-sense.  What can it be.  I changed all kinds of things around, from renaming the class, to changing the method name.  I was wondering if it followed some naming scheme like controllers and models do.  I don’t recall it needing to.

I decided to browse though the comments, see if anyone else ran into this.  And there is was, someone named, ianchadwick mentioned a way to make the namespace global in the web.config.  Well, damn, that is it, the view doesn’t know about my namespace BlogByEmail.Helpers.  I added @using BlogByEmail.Helpers; to the top of the page, and everything fell into place.

To use the helper in the view simply use @Html.Raw(Html.GenerateCaptcha())

Html.Raw is needed to keep MVC from HTML Encoding the output.

Damn I feel dumb sometimes.  …back to my code!

For some time now I have wanted to post to a blog from an email account.  Some blog engines these days have this functionality, like WordPress and TypePad.  Some through plug-ins and some built in.  I have used the WordPress plug-in on a test installation, and it works pretty well.  Though WordPress is probably my most preferred blogging engine, most of the time when I am installing blogs, it’s on a Microsoft stack and I am not big on running PHP on Windows.  On the Windows stack I really like using Blogengine.NET.  I find it to be a very capable blogging engine.  The only problem is, at least to date, I have not found a plug-in for it to post by email.  What it does support though is XML-RPC.

With the Help of the XML-RPC.NET library and a few hours away from the family, I through together a rough blog posting application.

I added in OpenPop.NET, a popmail client library I have used in the past, and now have a way to collect emails.  Now all I needed to do is tie them all together.

The outcome is Blog by Email (  An online service for setting up email accounts to post to blogging engines.  Besides looking like crap (I am using the generic MVC layout), it is functioning well. I am hoping my buddy will give me a hand coming up with a real design for the site.

The biggest challenge to setup posting to a blog is finguring out what XML-RPC entry point is, and what the blogging engine uses for the Blog Id.  The blog id is often the name of the blog, but I found in MovableType it uses the actual integer value assigned to that blog.  Bit of a pain to get that value.  A cool aspect of MovableType is that it generates a password to use for posting via XML-RPC.  A nice security feature.

Speaking of security, to protect the users entered credentials I am encrypting both usernames and passwords in the database.  Also, each user is given a unique key pair when the sign up with the service.  Little steps to make it harder to get this information in case someone does hack the application.


If you need to post to your blog from a POPMAIL email address, give Blog by Email a try.  The service is free (at least until it grows to the point where it needs a bigger web server).

While the site is getting off the ground and I get the code stable, registration is closed.  There is a form request an account.  I am looking for people to help test the system, so if you are interested please let me know.


Chomping at the bit to get ASP.NET MVC up and running on my regular hosting environment,, I sent their support a ticket today asking if they plan IIS7 installations in their shared hosting environment.

Brett Slaski
Posted On: 29 Apr 2009 10:50 AM


I just wanted to check to see if there is an ETA on any IIS7 installations for shared hosting?

Thank you,


Their response, unfortunately:

Clint Schleeper
Posted On: 29 Apr 2009 02:06 PM

Hi Brett,

At this time we have no plans for incorporating IIS7 into our shared hosting environment.

Customer Support
[email protected]
Local/International: 1.440.793.0323 x2
Toll-free: 1.800.593.0238 x2

So now I have work to do, find a host with a like offering as running IIS7, is there such an animal?  I have tried in the past and haven’t come up with anything so any suggestions is highly appreciated.

I find it ironic that I needed to send iHostasp the support ticket today, from work, out of the blue.  When I got home today, my copy of Professional ASP.NET MVC 1.0 arrived on the door step from Amazon.  A book I pre-ordered shortly after the release of Scott Gu’s free first chapter, now available in HTML.

Please post comments if you know of a good hosting company providing shared hosting of IIS7.

Thank you.

My current plan, which runs around $16/mo, $88.83 every 6 months.  I have to say the two things I like the best is dedicated memory pool for each domain and 3 MS SQL databases.  Three databases was the major reason I went with them in the first place.

  • Dedicated application pool for each domain!
  • Customer accessible database backups!
  • Storage – 2400MB
  • Bandwidth – 20GB
  • DNN Installations – 3
  • Parent portals – 60
  • Child portalsUnlimited
  • MSSQL 2005– 3 x 250MB each
  • MySQL 4/5 – 6 x 250MB each
  • MailUnlimited POP3/SMTP/IMAP/WEB MAIL Accounts. Accounts. MailFoundry spam & virus filtering included.
  • FTPUnlimited FTP accounts with ability to set user permissions.
  • Sub domains – Create & manage your own 3rd level domains.
  • Statistics – Detailed real-time statistics to track your visitors.
  • ASP.NET 1.1/2.0/3.0/3.5, ASP 3.0, PHP5 supported
  • Microsoft ASP.NET AJAX extensions
  • Can run wide array of other ASP, PHP, .NET based web applications without any limits

This is a bit silly, but I couldn’t resist.  I replied to their support email and simply said


And their reply:

Hi Brett,

We do not have IIS7 available within our shared hosting environment and do not have any plans to incorporate it in the near future. However, we do offer virtual dedicated server hosting environments and we could set you up with IIS7 on a virtual dedicated server. Our virtual dedicated server packages can be viewed at the link below.

iHost Virtual Dedicated Server Hosting Packages:

Customer Support
[email protected]
Local/International: 1.440.793.0323 x2
Toll-free: 1.800.593.0238 x2

UPDATE: (4/17/2010)

It was really interesting to me that the owner of left a message on this blog post about their service and how it was incorrect for their technician to say what they did.  But the truth holds; it is now April 17th of 2010 and still they have no known installations of II7 in their shared hosting environment.  What if I would of took him for his word and stayed with iHost?  I would be stuck and still without the environment I need.

Trying to make good of your company is one thing, making up stories is something completely different.

** To save you time of reading through this, you can’t cleanly use MVC on iHost**

I have been playing around with ASP.NET MVC for at least six months now and was estatic when the version 1.0 released during MIX09.  

Some time around preview 3 I wanted to put one of my MVC sites out at where I host all my Microsoft technology-based stuff.  I first hit a roadblock because the .NET 3.5 Framework wasn’t available for my domain.  I looked at iHost’s website and found it listed and asked, wtf?

It was a simple enough request, they just moved my domains over to one of their servers with the 3.5 framework installed.  The only issue this caused is that I lost all of my site statistics.  The moved forced me to reconfigure SmarterStats (a decent free offering from them) for the new server.  

Figured I was all set now, but no, MVC required IIS7 to work with regular routing.  Well it failed and I went over to godaddy and ran it on a free (came with domain purchase) server instance (which is horrible) for some testing, etc.  

Now I am back and documenting my findings for whatever.
First to note is that in the ASP.NET 1.0 Release Notes.doc file a reference is made to Phil Haack’s website for Bin Deploying ASP.NET MVC.  Searching for this on Phil’s site yeilds nothing, so I have linked it above.  

It’s really simple to do, just set the following references to “Copy Local”.


From VS2008, locate the references section in the Solution Explorer.  Locate each of the three references (dll’s) above, right click on them, and choose properties.  From the Properies view, change Copy Local: False to Copy Local: True.

That’s it.  When you compile or publish your solution the DLL’s for those three references will be added to the bin folder.  

After all of that, it still will not work as the routing will not work correctly without hacking iis settings a bit.  Forgot about this and I had actually tried all of this already about 45 days ago.  

As stated in Using ASP.NET MVC with Different Versions of IIS there are two options available for IIS6 and below:

  1. Modify your route table to use filenames (ewe)
  2. Create a wildcard script map (requires access to IIS) 

So the [my] only option is to wait for an unknown amount of time until decides to start ii7 installations.   Their support told me that they plan to, but have no schedule set. This is a real bummer about ASP.NET MVC, but I’ll get over it.  🙂

%d bloggers like this: