Tuesday, 22 November 2011

The resource cannot be found - /Account/Login

I ran into a problem the other day that I could find very little information about so I thought I’d put a blog post together to

a) remind me
b) hopefully help anybody else who runs into this problem.

I picked the obtuse title as it is very close to the ambiguous error message I got and should hopefully help other people find the solution far faster than I did.

Recently I was working on a MVC3 application, it was working well and I wanted to sort out dependencies for our CI server so that we didn’t need to have MVC installed on the server for the code to build and intended to do this by adding bin deployable dependencies.

I made a couple of small changes to views, a controller change to home and then clicked “Add Deployable Dependencies…” and when the dialog appeared I selected ASP.NET MVC

I then did a quick sanity check of build, run tests and run up the application before checking in only to find that when I ran the site up I got a yellow screen of death:


WTF! the unit tests had all passed and I had been testing the views themselves a moment or two ago by logging in and using the site. Unfortunately I hadn’t just made a single change since I last checked in (my bad) so I went back and checked all my changes one at a time to ensure that none of my changes could be causing the problem and found nothing.

I then took a closer look at the error and saw that the URL it was trying to request was /Account/Login which was incorrect as the name of the view that handled logging in was called Logon.  I checked the web.config and the found the default values hadn’t been changed:


I then tried changing Account to something as abstract as ABCDEF but got a similar error only instead of the requested URL being /Account/Login it was now /ABCDEF/Login. Something was incorrectly getting involved when redirecting to the loginUrl and altering the route to replace Logon with Login.

I then turned to Google and found…nothing, well nothing that seemed to apply to me that is.

This only left me with the unthinkable, could it be something to do with the deployable dependencies? I took a closer look at the assemblies that had been added and saw System.Web.Helpers.dll in the bin deployable folder which I know is linked with Web Matrix. I then did a bit of exploration with Reflector turned up no particular dependency on this assembly to any of the other bin deployable dependencies or any of my referenced assemblies and so I removed it and the site started working again!

A bit more focused Googling then turned up that the behaviour I was seeing was linked to  SimpleMembership in WebMatrix, I also noticed that  if you look at System.Web.Configuration and the FormsAuthentication class you will find that the property LoginUrl has a default value of login.aspx. I haven’t specifically tracked it back to this but it is suspicious and would certainly fit the behaviour I was seeing.

In my second Google attempt I had also found that if you don’t want to remove the assembly you can add
<add key="enableSimpleMembership" value="false" /> to the AppSettings of your web config and this will also allow the site to work, but why do you have to add this at all?

From forum posts and some blog posts I found it appears that you would perhaps use System.Web.Helpers in MVC if you wanted to use one of the helpers that you find in WebMatrix such as the Twitter helper and that the SimpleMembership provider was being called by default rather than the normal authentication mechanism in MVC resulting in the behaviour I was seeing.

IMHO when you add the bin deployable files in VS that includes System.Web.Helpers it should either:

a) add the missing web.config AppSetting for you
b) not add the assembly if its not needed
c) add the functionality without the need for the setting

    Hopefully this post may help somebody else who stumbles into this issue and save them the time it took me to work out why my working code suddenly became broken.


    1. Thank you a LOT!
      This helped me out big time :)


    2. Nice! thanks for posting


    3. Thanks a lot, just hit this problem now that I'm trying to set up for deployment. Not great timing...

    4. Thanks. You save me so much time!

    5. Me three. I really only needed to use the deployable dependencies for SqlServerCe, but in a bad move, I checked all three boxes. I had no idea that was related to this error until I found your blog.

      Thank you.

    6. Nicely done, I spent too much time trying to figure this issue out. This worked like a charm.

    7. Wow - Glad I finally learned just to Google these kinds of "WTF" problems before doing anything else. Your solution came right up and most assuredly saved my psyche, not to mention all the time it would have taken to figure this out! THANKS!

    8. A gazillion thanks!!

      Just ran into this problem as well. You saved us a lot of work in research, etc...

    9. You, sir, are a gentleman and a scholar!

      Thank you so much for taking the time to write this up. Not only did you help me solve the problem, but I also learned a great deal by the way you systematically approached the troubleshooting process.

      An excellent post!


    10. Thank you so much. I would never have figured that out.

    11. Incredible! You have save me hours of wailing and gnashing of teeth.

    12. Thank You,

      I was using Windows authentication and was using the identity to pull e-mail and other info from the Active Directory.
      Was working fine until I went to deploy it and clicked "Add Deployable Dependencies..."
      After that the User.Identity was not populated and it was looking for a login page.

      After half a day of wtf, google, try something, wtf, google, try something else, wtf.... I found this post.
      Adding the following setting to the appSettings section of the web.config file (as outlined in the post) did the trick for me:

    13. Thank you helped me

    14. You saved me a lot of time. Thanks!

    15. Thanks for the post. It saved me lots of time.