ASP.NET Get Form Text info to a Controller
18:04 04 Dec 2025

very new to asp.net. I'm trying to get a form to pass a person's name to a controller, and from there, display that person's LARP character info. Right now I'm only passing the character's name, class, species, and image as strings. Here's what I have so far.

Index View:

@{
    ViewData["Title"] = "Home Page";
}


        

Welcome To The LARP Character Database

Enter your user name above

Character View:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FinalProject.Models
{
    public class CharacterSheet
    {
        public string userName { get; set; }

        public string characterName;
        public string characterClass;
        public string characterSpecies;
        public string characterImage;
    }
}

Character Controller:

using FinalProject.Models;
using Microsoft.AspNetCore.Mvc;

namespace FinalProject.Controllers
{
    public class CharacterController : Controller
    {
        [HttpPost]
        public IActionResult Character(CharacterSheet characterSheet)
        {
            if(characterSheet.userName == "David")
            {
                characterSheet.characterName = "Gorbag The Mighty";
                characterSheet.characterClass = "Barbarian";
                characterSheet.characterSpecies = "Orc";
                characterSheet.characterImage = "ImageGoesHere";
            }

            return View(characterSheet);
        }
    }
}
Character View
@model FinalProject.Models.CharacterSheet;

@Model.characterName

@Model.characterClass

@Model.characterSpecies

@Model.characterImage

Thank you for your time, any assistance is appreciated!

c# asp.net .net asp.net-mvc razor