Click here to Skip to main content
15,888,733 members
Home / Discussions / Web Development
   

Web Development

 
GeneralMessage Closed Pin
24-Jan-19 11:19
Sarah George24-Jan-19 11:19 
GeneralRe: How do I insert dropdown Text, not the value, into the database? Pin
W Balboos, GHB25-Jan-19 1:14
W Balboos, GHB25-Jan-19 1:14 
GeneralRe: How do I insert dropdown Text, not the value, into the database? Pin
Richard Deeming25-Jan-19 2:33
mveRichard Deeming25-Jan-19 2:33 
QuestionOne Step Forward, Two Steps Back - Can't create controller using scaffolding Pin
#realJSOP10-Nov-17 2:04
mve#realJSOP10-Nov-17 2:04 
AnswerRe: One Step Forward, Two Steps Back - Can't create controller using scaffolding Pin
#realJSOP11-Nov-17 11:16
mve#realJSOP11-Nov-17 11:16 
QuestionSys.WebForms.Res is undefined when javascript executed inside updatepanel Pin
Claudio Trenca8-Nov-17 4:38
professionalClaudio Trenca8-Nov-17 4:38 
QuestionMVC5 - Logoff does not work in Chrome Pin
#realJSOP7-Nov-17 1:59
mve#realJSOP7-Nov-17 1:59 
AnswerRe: MVC5 - Logoff does not work in Chrome Pin
Richard Deeming7-Nov-17 2:22
mveRichard Deeming7-Nov-17 2:22 
John Simmons / outlaw programmer wrote:
What's the reason for that?

Because that's how it's declared in Views\Shared\_LoginPartial.cshtml:
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
    using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
    {
    @Html.AntiForgeryToken()

    <ul class="nav navbar-nav navbar-right">
        <li>
            @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
        </li>
        <li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
    </ul>
    }
}
else
{
    ...

It's using a <form> because the LogOff action in the AccountController requires a POST request:
C#
//
// POST: /Account/LogOff
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult LogOff()
{
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
    return RedirectToAction("Index", "Home");
}

This is done to prevent a forged request from another site from logging the user out of your site. If you're not worried about that, you could remove the [HttpPost] and [ValidateAntiForgeryToken] attributes to make the action accept a GET request, and then remove the form:
@using Microsoft.AspNet.Identity
@if (Request.IsAuthenticated)
{
    <ul class="nav navbar-nav navbar-right">
        <li>
            @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
        </li>
        <li>
            @Html.ActionLink("Log off", "LogOff", "Account")
        </li>
    </ul>
}
else
{
    ...
C#
//
// GET: /Account/LogOff
public ActionResult LogOff()
{
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
    return RedirectToAction("Index", "Home");
}

Otherwise, you'll need to work out why the javascript: link isn't working in Chrome. The developer console (F12) might have some clues.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: MVC5 - Logoff does not work in Chrome Pin
#realJSOP7-Nov-17 2:39
mve#realJSOP7-Nov-17 2:39 
GeneralRe: MVC5 - Logoff does not work in Chrome Pin
Richard Deeming7-Nov-17 2:45
mveRichard Deeming7-Nov-17 2:45 
GeneralRe: MVC5 - Logoff does not work in Chrome Pin
#realJSOP7-Nov-17 2:47
mve#realJSOP7-Nov-17 2:47 
GeneralRe: MVC5 - Logoff does not work in Chrome Pin
Richard Deeming7-Nov-17 2:53
mveRichard Deeming7-Nov-17 2:53 
GeneralRe: MVC5 - Logoff does not work in Chrome Pin
#realJSOP7-Nov-17 2:59
mve#realJSOP7-Nov-17 2:59 
GeneralRe: MVC5 - Logoff does not work in Chrome Pin
Richard Deeming7-Nov-17 3:03
mveRichard Deeming7-Nov-17 3:03 
GeneralRe: MVC5 - Logoff does not work in Chrome Pin
#realJSOP7-Nov-17 3:01
mve#realJSOP7-Nov-17 3:01 
AnswerRe: MVC5 - Logoff does not work in Chrome Pin
aijaj hussain18-Nov-17 20:09
aijaj hussain18-Nov-17 20:09 
QuestionMVC5 checkbox size (RESOLVED - kinda) Pin
#realJSOP1-Nov-17 2:37
mve#realJSOP1-Nov-17 2:37 
AnswerRe: MVC5 checkbox size Pin
Richard Deeming2-Nov-17 5:53
mveRichard Deeming2-Nov-17 5:53 
GeneralRe: MVC5 checkbox size Pin
#realJSOP2-Nov-17 8:06
mve#realJSOP2-Nov-17 8:06 
AnswerRe: MVC5 checkbox size Pin
#realJSOP3-Nov-17 3:50
mve#realJSOP3-Nov-17 3:50 
SuggestionRe: MVC5 checkbox size Pin
Richard Deeming3-Nov-17 5:07
mveRichard Deeming3-Nov-17 5:07 
GeneralRe: MVC5 checkbox size Pin
#realJSOP3-Nov-17 6:09
mve#realJSOP3-Nov-17 6:09 
GeneralRe: MVC5 checkbox size Pin
Richard Deeming3-Nov-17 10:02
mveRichard Deeming3-Nov-17 10:02 
GeneralRe: MVC5 checkbox size Pin
#realJSOP3-Nov-17 6:12
mve#realJSOP3-Nov-17 6:12 
JokeRe: MVC5 checkbox size Pin
Richard Deeming3-Nov-17 10:03
mveRichard Deeming3-Nov-17 10:03 

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.