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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:56:40+00:00 2026-05-23T00:56:40+00:00

I am working just one week with ASP.NET MVC 3. This might be a

  • 0

I am working just one week with ASP.NET MVC 3. This might be a very basic question or someone might have asked similar question before. I am seeking help to show me right path/method to accomplish the problem I am facing getting the partial view designed.

I have created a partial view login (in side bar) as below. What I would like to achieve here is, when I hit the “login” button, I must be a able update the partial view with information such as

**Welcome [UserName]

Last SuccessFul Login : [DateTime]

Member Since : [Date]**

I am not sure if I need to create another partial view to display this information Or the login partial view can be updated on the fly based on the action.

Login Partial View

@model AlanBeezLab.Models.LoginModel
@using (Ajax.BeginForm("Login","UserLogin", new AjaxOptions { UpdateTargetId =Model.UserName }))
{
    <div >User Name
    @Html.TextBox(" ")
    </div>
    <div>Password
    @Html.Password(" ")
    </div>
    <p><input type="submit" value="Let me in!" /></p>

}

Below is the _Layout.cshtml

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
       <!--link href="@Url.Content("~/Content/Site.css")" rel="stylesheet"    type="text/css" />-->
      <link href="@Url.Content("~/Content/SiteStyle.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
</head>

<body>
   <div id="Header" style="background-image: url('/Content/Images/Banner_Final3.png'); background-repeat:no-repeat; width :1500px; height : 150px;"   >

   </div>
  <div id="SideBar">
       @Html.Partial("UserControls/UserLogin", new AlanBeezLab.Models.LoginModel())
   </div>
   <div id="Content">
        @RenderBody()
   </div>
   <div id="Footer">
        <p>Copyright &copy; XXXXX</p>
   </div>
</body>
</html>

Below is the Login Controller

public class UserLoginController : Controller
{
    //
    // GET: /UserLogin/

    public ActionResult Index()
    {
        return View();
    }

    public ActionResult LogIn()
    {
        return [Not Sure];
    }

I am not sure if this is best/right approach to accomplish this. I would appreciate if I am directed to the right path/approach.

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-05-23T00:56:41+00:00Added an answer on May 23, 2026 at 12:56 am

    I’ve had this discussion with my peers before.

    IMO login/logout should not be done via AJAX, it should be a regular HTTP POST.

    Why? Well what if your on a page that requires Administrator access, then you logout via AJAX? Your still on the page – when you shouldn’t be authorized to do so (unless of course you update the main portion of the page as well, which is kind of silly)

    So my advice – make the login button do a regular POST to an action method, then use the PRG pattern to redirect back to the original page.

    Of course, if you don’t have the concept of administrators/permissions/roles then an AJAX login/logout will be fine.

    Regardless, you’ve done the right thing with the partial view.

    Your partial view should figure out if the user is authenticated, then render an appropriate editor/display template based on that.

    E.g: _Login.cshtml:

    @if(Request.IsAuthenticated) {
       @Html.DisplayFor(Context.User.Identity)
    } else {
       @* editor fields *@
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just started working with ASP.NET MVC now that it's in beta. In my
I've just started working on an ASP.NET project which I hope to open source
I have a Linq to SQL query that was working just fine with SQL
I have just been re-working an old bit of compiler-like code written using bison.
I just ran across this error message while working in C# A property or
I was just working on a function that I needed to return two values,
I just started working for a pretty large company and my group manages all
I just got done working through the Django tutorials for the second time, and
I'm just getting started working with foreign keys for the first time and I'm
I'm working on a project which is just about to start, and since I

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.