Click here to Skip to main content
15,867,956 members
Articles / Web Development / ASP.NET

The Resource Cannot Be Found - /Account/Login

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
30 Nov 2011CPOL4 min read 58.4K   3   16
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 then 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 it's 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.

This article was originally posted at http://designcoderelease.blogspot.com/feeds/posts/default

License

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


Written By
Nock Consulting
United Kingdom United Kingdom
Passionate developer, designer, Certified Scrum Professional, wanna-be architect, agile evangelist, and presenter.

Comments and Discussions

 
QuestionYou are a life saver... Pin
Member 939943120-Jul-14 8:38
Member 939943120-Jul-14 8:38 
QuestionJust perfect! Pin
FredericSivignonPro7-Feb-14 1:42
FredericSivignonPro7-Feb-14 1:42 
AnswerRe: Just perfect! Pin
Nathan Gloyn7-Feb-14 1:56
Nathan Gloyn7-Feb-14 1:56 
GeneralRe: Just perfect! Pin
FredericSivignonPro7-Feb-14 1:58
FredericSivignonPro7-Feb-14 1:58 
GeneralThank you! Pin
DaveyGun23-Apr-13 12:35
DaveyGun23-Apr-13 12:35 
Questionit helped me out big time thank you so much! Pin
Member 820133520-Mar-13 19:12
Member 820133520-Mar-13 19:12 
QuestionBrilliant solution Pin
Bikee11-Jun-12 19:19
Bikee11-Jun-12 19:19 
GeneralThanx a bunch! Pin
jarlem9-May-12 3:39
jarlem9-May-12 3:39 
QuestionThanks so much Pin
Alan Dale Fisher19-Apr-12 6:17
Alan Dale Fisher19-Apr-12 6:17 
QuestionAny ramifications/side-effects of this fix that one needs to be aware of? Pin
Member 833134130-Nov-11 19:50
Member 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? Pin
Nathan Gloyn30-Nov-11 21:16
Nathan Gloyn30-Nov-11 21:16 
QuestionThank you Thank you Thank you Pin
Member 833134130-Nov-11 19:47
Member 833134130-Nov-11 19:47 
AnswerRe: Thank you Thank you Thank you Pin
Nathan Gloyn30-Nov-11 21:10
Nathan Gloyn30-Nov-11 21:10 
AnswerRe: Thank you Thank you Thank you Pin
Evgeny_Rokhlin30-Nov-11 22:11
Evgeny_Rokhlin30-Nov-11 22:11 
AnswerRe: Thank you Thank you Thank you Pin
Ray Linder | Glacsy.com6-Dec-11 10:47
Ray Linder | Glacsy.com6-Dec-11 10:47 
AnswerRe: Thank you Thank you Thank you Pin
Mark Shortt11115-Mar-12 23:47
Mark Shortt11115-Mar-12 23:47 

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

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