Click here to Skip to main content
Click here to Skip to main content

The resource cannot be found - /Account/Login

By , 30 Nov 2011
 

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)

About the Author

nathans.dropbox@googlemail.com
Software Developer (Senior) Dot Net Solutions
United Kingdom United Kingdom
Member
Passionate developer, designer, Certified Scrum Professional, wanna-be architect, agile evangelist, and presenter.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralThank you!memberDaveyGun23 Apr '13 - 12:35 
Whew.
Questionit helped me out big time thank you so much!memberMember 820133520 Mar '13 - 19:12 
it helped me out big time thank you so much!
QuestionBrilliant solutionmemberBikee11 Jun '12 - 19:19 
You saved my day, thanx.
GeneralThanx a bunch!memberjarlem9 May '12 - 3:39 
This articel got me out of 1,5 days of IIS 7 / ASP.NET MVC3 misery! Wink | ;)
QuestionThanks so muchmemberAlan Dale Fisher19 Apr '12 - 6:17 
I was just about to give up on this project and start another. I am using Windows Autentication and everything was working fine until I went to publish to am IIS server and had trouble with missing references. I then fond a post saying to go to Project "Add Deployable Dependancies" and thats when I started having the issue with the resource cannot be found /Account/Login. I aded to my web config and it works but I would like to remove the reference that is the root of the issue but not sure which one you are refering to.
QuestionAny ramifications/side-effects of this fix that one needs to be aware of?memberMember 833134130 Nov '11 - 19:50 
I just applied this fix after reading your article. Although it has fixed the /account/login error, I was wondering if there are any other ramifications of this change to web.config. Thoughts?
AnswerRe: Any ramifications/side-effects of this fix that one needs to be aware of?memberNathan Gloyn30 Nov '11 - 21:16 
As that config setting is only used by WebHelpers code there is very little chance that you should find any issues.
 
Personally I tend to remove the assembly entirely rather than add the config setting but this is because I know the code isn't, and won't, be using the functionality that is contained in the WebHelpers assembly.
 
I also did some extensive Googling when writing up the post and its funny that when I had the problem I couldn't find anything but as soon as I knew what it was I found several articles on it all with the same fixes.
 
If you do happen to run into some anomalous behaviour please let me know.
 
Cheers
 
Nathan
QuestionThank you Thank you Thank youmemberMember 833134130 Nov '11 - 19:47 
I just ran into this issue today. Your post saved me a load of pain. Thanks a ton.
AnswerRe: Thank you Thank you Thank youmemberNathan Gloyn30 Nov '11 - 21:10 
No problem, glad it helped
AnswerRe: Thank you Thank you Thank youmemberEvgeny_Rokhlin30 Nov '11 - 22: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]memberRay Linder | Glacsy.com6 Dec '11 - 10:47 
Just want to thank you for researching this and finding the cause of this particular issue. I've ran into this myself and had to implement a "redirect" workaround. Now, I know how to resolve this issue correctly. Thank you, again...
Ray Linder
Chief Executive Officer
Glacsy | Glacsy.com
http://www.glacsy.com
 
"Impossibility doesn't exist."


modified 6 Dec '11 - 16:58.

AnswerRe: Thank you Thank you Thank youmemberMark Shortt11115 Mar '12 - 23:47 
I also want to add my thanks - saved a lot of work

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 30 Nov 2011
Article Copyright 2011 by nathans.dropbox@googlemail.com
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid