ServerStuff/Settings.aspx.cs

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Settings : System.Web.UI.Page
{
    protected UserProfile UserProfile
    {
        get
        {
            return SecurityContextManager.GetUserProfile(Context);
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Save_Button_Click(object sender, EventArgs e)
    {
        var userStorePath = Server.MapPath("~/App_Data");

        var firstName = Request["firstname"];
        var lastname = Request["lastname"];
        var currentPassword = Request["current_password"];
        var newPassword = Request["new_password"];
        var confirmPassword = Request["confirm_password"];

        var userProfile = this.UserProfile;
        try
        {
            if (!string.IsNullOrEmpty(newPassword))
            {
                if (newPassword != confirmPassword)
                {
                    MessagePanel.Visible = true;
                    Message.Text = "Password and confirmation does not match.";
                    return;
                }

                if (!LoginProvider.Validate(userStorePath, userProfile.Username, currentPassword))
                {
                    MessagePanel.Visible = true;
                    Message.Text = "Invalid old password or new passwords are in invalid format.";
                    return;
                }
            }

            userProfile.Firstname = firstName;
            userProfile.Lastname = lastname;
            LoginProvider.UpdateProfile(userStorePath, userProfile);
            Response.Redirect("Breakout.aspx");
        }
        catch (Exception x)
后面还有 6 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。