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

  • Home
  • SEARCH
  • 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 4080622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:57:13+00:00 2026-05-20T17:57:13+00:00

I’m learning ASP.NET MVC3 and I’m now examining the user handling. My first problem

  • 0

I’m learning ASP.NET MVC3 and I’m now examining the user handling.
My first problem would be (I know there is a lot about this subject in other threads, I just fail to find a good one with MVC3) that I want the login page to redirect me where I came from, or where I was redirected from.
In php perhaps I would add this url to the querystring, maybe.
But I need a way to do this somehow automatically, and this is a so common design pattern I was wondering if there is a “built in” way to do this.

What would be the cleanest, or preferred way to do this?

Also when I’m redirecting to a login page which would be the best way for checking and storing the url which I’m redirected from? I would check for the referrer in the request object and spit it out in the url as “?redirect=protected.html” but I’m not even sure how to properly do this.

Any advice on this subject would be appreciated.

  • 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-20T17:57:14+00:00Added an answer on May 20, 2026 at 5:57 pm

    MVC works the same way as ASP.NET.

    If you use Forms Authentication a lot of those questions will be answered for you.

    In your Web Config find the line that says authentication="Windows" and then change that to Forms

    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" />
    </authentication>
    

    MVC 3 will actually give you the Account/LogOn route as part of the MVC 3 template project (check your models and see if you have one called AccountModel).

    Then you just add Authorization to deny all users to your site:

    <authorization>
      <deny users="?"/>
    </authorization>
    

    by default this will send any person coming to your site off to your login.

    So after you have validated that there login credentials are correct you set the AuthCookie the same as ASP.NET:

    FormsAuthentication.SetAuthCookie(userName, false);
    

    Form this you can the redirect to where ever you want.

    to redirect back to where you came from use:

    FormsAuthentication.RedirectFromLoginPage(userName, false);
    

    Not forgetting the other useful statement of:

    FormsAuthentication.SignOut();
    

    Without Authentication the site wont let you access anywhere until you are logged in, so the CSS will stop working.

    The locations I have added to make sure this doesnt happen are as follows:

    <location path="Content">
     <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
     </system.web>
    </location>
    <location path="Scripts">
     <system.web>
      <authorization>
        <allow users="?"/>
      </authorization>
     </system.web>
    </location>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I have text I am displaying in SIlverlight that is coming from a CMS
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.