Click here to Skip to main content
15,906,624 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey fellas,

As you know, MVC4 comes with an "out of the box" account controller that controls the login and registration. They also coded in the Authorization configurations for External Logins such as Facebook, Twitter, etc. Well, here is the thing. They have it set up so that a login/register section is coded in a @Html.Partial("_LoginPartial"). This only shows the login and the register buttons that go to each individual model.

I was trying to cut a step out. I want to place the Login form (Login Model) directly on the home page, and add the register and facebook login buttons underneath of it so that the user can chose to fill out the form and login, use facebook, or register. I think I did that part right but the login form is not loging in, and the facebook login is giving me the following error ( which I know what it means,but I cant figure out what they want in there to call the right URL

Also, where the "FB" is, there should be login with facebook image that I coded in a css id=facebook. And it doesn't show unless I write something in place of "FB" long enough to show the entire image.

 The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Account/_ExternalLogin

This is my code in the Home page

<h2>Members Area</h2>
            <section id="contact-form">
                @using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
                <div id="membership">
                            @Html.LabelFor(m => m.UserName)
                            @Html.TextBoxFor(m => m.UserName)
                            @Html.ValidationMessageFor(m => m.UserName)
                            @Html.LabelFor(m => m.Password)
                            @Html.PasswordFor(m => m.Password)
                            @Html.ValidationMessageFor(m => m.Password)
                            @Html.CheckBoxFor(m => m.RememberMe, new { @class = "checkbox" })
                            @Html.LabelFor(m => m.RememberMe)
                        <li><button style="float:left; margin-left: 0px !important; margin-top:15px, " type="submit" value="Log in">Log in</button></li>
                        <li>@Html.ActionLink("Register", "Register", "Account", routeValues: null, htmlAttributes: new { id = "registerLink" }) </li>
                <section class="social" id="socialLoginForm">
                    @Html.ActionLink("FB", "_ExternalLogin", "Account", null, new { id = "facebook" }) 

                @section Scripts {

I am also including
@model WebsiteManager.Models.LoginModel
to call the login model

And the live site is[^]

I'll appreciate the help

p.s. the rest of the code was untouched. It is basically the same as it came in the box.
Updated 26-May-13 6:54am
Zoltán Zörgő 26-May-13 13:26pm    
And do you have _ExternalLogin action in Account controller?
[no name] 26-May-13 13:30pm    
I do, you may see it in this codepad
Zoltán Zörgő 26-May-13 13:42pm    
As I see, you don't have any! You should have a method like
public ActionResult _ExternalLogin()...

But I haven't seen anything like this. Even without underscore.
[no name] 26-May-13 13:53pm    
I do have it. Check the bottom of the code in the codepad I addressed above

It looks like this
public ActionResult ExternalLogin(string provider, string returnUrl)
return new ExternalLoginResult(provider, Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
Zoltán Zörgő 26-May-13 15:14pm    
That is not the same. You have put a link to an action. That link requires Get. This method is available only with post. And it has no underscore at the beginning either. I repeat, you don't have the action you are referring.

1 solution

After examining your code, I have noticed, that you are missing the proper action method in your controller. You have put a link to an action. That link requires GET http method. And the name should have an underscore at the beginning. You don't have the action you are referring to. You should have a method with following signature:
public ActionResult _ExternalLogin()...
Share this answer
[no name] 28-May-13 19:19pm    
I'm sorry, It didn't work. I just reverted the changes back to the pout of the box option and deal with it later
Zoltán Zörgő 29-May-13 2:09am    
Well, I gave you a solution for the error message, not your concept. If you did it right, the concrete error you got should have gone. But others might raise...

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900