Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2007
    Posts
    22

    Authorization error in Video - 04 (Comprehensive ASP.NET MVC)

    I ran into an issue at about 18:30 minutes into the Authorization video:

    After modifying the Login action method to include a (string returnUrl) parameter,
    returnUrl remains NULL even after logging in with a username that is authorized when the
    form is posted. I set a break point to check this. As a result, I'm always redirected to the Home page.

    [HttpPost]
    public ActionResult Login(AuthLogin form, string returnUrl)
    {
    ...
    ...
    FormsAuthentication.SetAuthCookie(form.Username, true);

    if (!string.IsNullOrWhiteSpace(returnUrl))
    {
    return Redirect(returnUrl);
    }

    return RedirectToRoute("Home");
    }

    Can somebody help?

  2. #2
    Join Date
    Jun 2012
    Location
    probably at a PC
    Posts
    309
    I'm assuming you did the step with the <authentication> block in the /Web.config right?

    Did you try navigating to a different page first, instead of only refreshing? It may not be aware of a different page to redirect to when you start the request on the login page. (might be a stupid question. if so, I apologize)


    NOTE: Just for future reference, it's much easier to read and more pleasant to look at when you make use of the [code] block bb-code in your post for code-snippets, like so:
    [code]...your code...[/code]
    Last edited by nGAGE; 10-20-2013 at 06:47 AM.

  3. #3
    Join Date
    Feb 2013
    Location
    Gothenburg, Sweden
    Posts
    40
    I think that what you describe is the correct action to happen when you do what you say you do. Do this:

    Try to login as a non-admin person. Then type the Url: /admin/posts
    You will be redirected to the login screen with the url:/login?ReturnUrl=%2fadmin%2fposts
    When you have that in the address bar you login as an admin person. You will be redirected to
    the Url: /admin/posts.

    Am I right? Did I understand your problem right?

  4. #4
    Join Date
    Feb 2007
    Posts
    22
    @mikael1000 - Yes, you are right. Thanks for clarifying.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •