Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:51:30+00:00 2026-05-26T11:51:30+00:00

When I first visit my site using URL: http://mysite.com/myapp , I am redirected to

  • 0

When I first visit my site using URL: http://mysite.com/myapp, I am redirected to the login page, but the returnUrl is “/myapp”.

How do I ensure that upon first visit, it redirects to the login page, but the return URL is something other than the login page itself, such as “~/Home/Index”.

I have tried adding a routes.MapRoute, passing an empty string to the “url” parameter, and in the object passed to “defaults” I include a value for the returnUrl member as “~/Home/Index”, but that’s not affecting anything.

I’ve tried creating a default document, and ensuring full anonymous access to it an the login page, but that’s not working either… it always redirects and appends a returnUrl of the login page itself, which is dumb. This seems to be a problem with the default behavior of the routing system when property security is in place.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:51:30+00:00Added an answer on May 26, 2026 at 11:51 am

    I figured it out.

    The default IIS security mechanism for securing pages (i.e. the system.web/authorization section) is useless when using MVC, because with MVC you’re not securing actual physical pages or paths, but rather controllers and actions referenced through virtual paths called “routes”.

    Instead of being able to secure everything with one line in web.config, you have to remember to add an [Authorize] attribute to every action you want secured (or to each controller class on which you want all actions secured), because everything is accessible by default. This means your security is code-based in MVC, rather than web.config-based, so you cannot change the settings without recompiling.

    The exact problem here was that I was securing the app root directory with the authorization section, and was unable to add exceptions for physical sub-paths… because there really are none in MVC.. it’s all handled by the routing module. Therefore, when visiting the root with no exceptions possible, the forms authentication module was kicking in saying “no, you cannot access the root path” and was immediately serving the login page and adding a redirect back to the secured root.

    Normally, having the default route go to Account/LogOn, would be fine, because Account/LogOn has code to redirect to Home/Index in the absense of a returnUrl. However, in this case, the authorization section was causing a returnUrl to be generated by forms authentication, which sabataged the ability of the Account/LogOn action to perform a default redirect. Changing the default route to Home/Index fixed that problem; however this left the browser’s URL incorrect, and that’s when I ran into the problem of URL’s being specified as “../Content/image.jpg”, rather than @Url.Content(“~/Content/image.jpg”).

    So as you can see, this was a complex, multifaceted problem here that arose from a clash of architectures.

    See: Problem with Authorization with IIS and MVC

    and

    See: How do I allow all users access to one route within a website with integrated auth?

    To summarize, good suggestions were 1: default route should go to home rather than login, 2: ensure you let the framework generate content URLs relative to application root, 3: add to the http-get action of the login page a redirect to home if Request.IsAuthenticated is true, and 4: use [Authorize] attribute to secure action methods.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a RoR site that loads a splash page on the first visit.
I'm developing a site where on first visit, the user will be asked to
I got two related problems in the site root. First, both domain.com and www.domain.com
For my site I am using a login system much like the one on
In Chrome, and possibly other browsers, when you first visit my site , you'll
First, let's get the security considerations out of the way. I'm using simple authentication
First off, I am using Windows XP. I have multiple hard drives and it
First of all, I know how to build a Java application. But I have
First off: I'm using a rather obscure implementation of javascript embedded as a scripting
I am trying to create a web page using php. The problem is that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.