© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
15 replies
EnderLeWolf

✅ MVC to Blazor

Hello! so awhile ago, I made an mvc. I am now attempting to port the code over into a new blazor project but am unsure on how to do this, as with the mvc I had 1 view called Events, which would get opened via clicking a button in a drop down menu that would open the view with different data based on which drop down button you clicked. but with Blazor, through all my research I don't think it is possible to return a page as such. here is some of my code from the mvc, any help would be greatly apricated!


The event controller:
public async Task<IActionResult> Index(int id)
{
  List<Event> events = _context.Event.AsNoTracking()
  .Where(c => c.EventTribe == id && c.EventStatus == 1 ||  c.EventTribe == 11 && c.EventStatus == 1)
  .OrderBy(c => c.EventYear)
  .ToList();

  if (events == null)
  {
    return RedirectToAction("Index", "Home");
  }

  return View(events);
}
public async Task<IActionResult> Index(int id)
{
  List<Event> events = _context.Event.AsNoTracking()
  .Where(c => c.EventTribe == id && c.EventStatus == 1 ||  c.EventTribe == 11 && c.EventStatus == 1)
  .OrderBy(c => c.EventYear)
  .ToList();

  if (events == null)
  {
    return RedirectToAction("Index", "Home");
  }

  return View(events);
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

MVC + Blazor Proper approach
C#CC# / help
4y ago
Trying to understand MVVM and MVC. Blazor ASP.NET
C#CC# / help
2y ago
mvc not finding blazor item, 404 not found
C#CC# / help
3y ago
Integrate Blazor components inside MVC .NET Framework 4.8
C#CC# / help
2y ago