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 8270935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:43:15+00:00 2026-06-08T06:43:15+00:00

A fellow developer and I are porting a WebForms project over into MVC3, and

  • 0

A fellow developer and I are porting a WebForms project over into MVC3, and we’re new to this. We’ve got our WebForms master page ported to an MVC3 layout page, but the one thing that throws us is the Session for a logged in user.

In the WebForms master page, we check the Session to make sure Session(“LoggedInUser”) has a value, and if not, redirect to login page.

We’re not sure how to replicate this in MVC3, and my googling has come up short. It seems kinda evil to place that sort of logic in the layout page, but maybe I’m nuts. Surely, there’s a better way to do this than putting a check like that in every single action method… If someone could point us in the right direction, we’ll gladly dive in and research.

Much thanks.

  • 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-06-08T06:43:16+00:00Added an answer on June 8, 2026 at 6:43 am

    All you have to do is add [Authorize] tag on all controllers. It’ll automatically redirect you to login page specified in web.config if you are not logged in.

    Even better you could create a BaseController from which each other controller will inherit.

    BaseController

    [Authorize]
    public abstract class BaseConroller : Controller
    {
    
    }
    

    Other controllers

    public class HomeController : BaseController
    {
    
    }
    

    Each action in HomeController will redirect based on your FromsAuthentication settings.

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

Sidebar

Related Questions

A fellow developer on a project I am on believes that doctests are as
A fellow developer and I are putting together a proposal for a new application,
We recently had a bug, after a fellow developer changed a RegExp literal into
The comments here got me thinking. If you are a new Developer without a
A fellow developer and I are conversing (to put it lightly) over Lazy-Loading of
A fellow developer changed all the values in the userid column of table map
I was looking at some code of a fellow developer, and almost cried. In
I'm after some design advice. I'm working on an application with a fellow developer.
One of my fellow developer has a code similar to the following snippet class
I was recently berated by a fellow developer for using string math in an

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.