Click here to Skip to main content
Click here to Skip to main content
Technical Blog

The resource cannot be found - /Account/Login

, 30 Nov 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
How to solve this issue.

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:

  1. remind me
  2. 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 an 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:

image

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:

image

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:

  1. add the missing web.config AppSetting for you
  2. not add the assembly if its not needed
  3. 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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nathan Gloyn
Nock Consulting
United Kingdom United Kingdom
Passionate developer, designer, Certified Scrum Professional, wanna-be architect, agile evangelist, and presenter.
Follow on   Twitter

Comments and Discussions

 
QuestionYou are a life saver... PinmemberMember 939943120-Jul-14 9:38 
QuestionJust perfect! PinmemberFrederic Sivignon7-Feb-14 2:42 
AnswerRe: Just perfect! Pinmembernathans.dropbox@googlemail.com7-Feb-14 2:56 
GeneralRe: Just perfect! PinmemberFrederic Sivignon7-Feb-14 2:58 
GeneralThank you! PinmemberDaveyGun23-Apr-13 13:35 
Questionit helped me out big time thank you so much! PinmemberMember 820133520-Mar-13 20:12 
QuestionBrilliant solution PinmemberBikee11-Jun-12 20:19 
GeneralThanx a bunch! Pinmemberjarlem9-May-12 4:39 
QuestionThanks so much PinmemberAlan Dale Fisher19-Apr-12 7:17 
QuestionAny ramifications/side-effects of this fix that one needs to be aware of? PinmemberMember 833134130-Nov-11 20:50 
AnswerRe: Any ramifications/side-effects of this fix that one needs to be aware of? PinmemberNathan Gloyn30-Nov-11 22:16 
QuestionThank you Thank you Thank you PinmemberMember 833134130-Nov-11 20:47 
AnswerRe: Thank you Thank you Thank you PinmemberNathan Gloyn30-Nov-11 22:10 
AnswerRe: Thank you Thank you Thank you PinmemberEvgeny_Rokhlin30-Nov-11 23:11 
I found a few very similar issues by googling, but none was exactly the same as this one and none of the solutions helped.
 
I just gasped when I saw this articles describes exactly what happened to me, step by step - worked on local PC, installed deployable dependencies, installed on the server, noticed the url difference ...
 
A very timely post and worked like a charm!
AnswerRe: Thank you Thank you Thank you [modified] PinmemberRay Linder | Glacsy.com6-Dec-11 11:47 
AnswerRe: Thank you Thank you Thank you PinmemberMark Shortt11116-Mar-12 0:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411023.1 | Last Updated 30 Nov 2011
Article Copyright 2011 by Nathan Gloyn
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid