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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:59:17+00:00 2026-05-23T17:59:17+00:00

I have a Razor site I made with full login/registration and Admin roles with

  • 0

I have a Razor site I made with full login/registration and Admin roles with WebMatrix. And a requirement is for the administrator to be able to “Login as an existing user” in order to be able to add to, edit, cancel and or confirm new orders for that particular user he is logged in as.

I know this is not the most common way of approaching this, but I have seen it done alot. I currently own a domain reselling business and my supplier uses this type of feature where it lets me login as a user to credit their account ETC..

So, I’ve been told that FormsAuthentication would work good for this in C#. So I checked out:

http://msdn.microsoft.com/en-us/library/twk5762b.aspx

Which leads me to ask:

What?

And…

By “username”, they mean the e-mail address that’s created when that user registered? Or do they mean the UserId, which is an INT?

And, is it really as simple as doing this?:

@{
  if(Roles.IsUserInRole("Administrator"))
  {
    SetAuthCookie(
      "ClientsUserNameHere,
      true
    );
  }
  else
  {
    Response.Redirect("~/Account/SignIn");
  }
}
<DOCTYPE! HTML>
<html>
  <head></head>
  <body>
    <p>Hello, Administrator, you are currently Signed In as [insert client name here].</p>
  </body>
</html>
  • 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-23T17:59:17+00:00Added an answer on May 23, 2026 at 5:59 pm

    And, is it really as simple as doing this?

    Yes, it is really that simple. Well, actually for this to take effect you need to redirect because the page will use the request cookie which still indicates an administrator:

    if(Roles.IsUserInRole("Administrator")) {
        FormsAuthentication.SetAuthCookie(
            "ClientsUserNameHere",
            false // <-- set to true only if you want persistent cookies
        );
        Response.Redirect("~/Home/SomeUserPage");
    }
    

    In addition you could store some info into the session indicating that this is an administrator acting as a normal user (if you ever needed to know it) and not the normal user.

    You might also take a look at the following article for a more advanced impersonation scenario.

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

Sidebar

Related Questions

I have a site search (using Examine & Razor) that breaks if a space
I have developed a website using Razor (Microsoft WebMatrix) and now I want to
I have a site where employees can login and manage things. Each employee has
I have a web site in asp.net mvc 3 razor and have some range
I have converted a site over entirely to Razor and want it to ignore
i have made an application in asp.net mvc3/c#/Razor , now i want to implement
I have an MVC3 (razor) site published to IIS7 locally for testing purposes. When
I have something like this in Site.Master in an asp.net mvc3 (not razor) project:
I'm new to using Razor and ASP.NET. I currently have a site I'm trying
I have a WebGrid on my Razor-based site and now I would like to

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.