public IActionResult InertiaResultOrRedirect(string componentName, object props = null) { // if this is not an inertia request, redirect to do a full page load to initialize Inertia props ??= new { }; return(IsInertiaRequest ? (IActionResult)Inertia.Render(componentName, props) : RedirectToAction("Index", new { redirectComponent = "Home/SampleApi" })); }
public IActionResult Index() { //return whatever you want. var data = new { Id = 1 }; //return Inertia Result. return(Inertia.Render(_componentResolver.ResolveComponent(nameof(Index)), data)); }
public IActionResult Privacy() { //return whatever you want. var data = new { Id = 1 }; //return Inertia Result. var result = Inertia.Render(_componentResolver.ResolveComponent(nameof(Privacy)), data); return(result); }
public IActionResult Index() { //your js component file name. var componentName = "Welcome"; //return whatever you want. var data = new { Id = 1 }; //return Inertia Result. return(Inertia.Render(componentName, data)); }
public IActionResult Index() { //your js component file name. var componentName = "Counter"; //return whatever you want. var data = new { initialValue = 0 }; //return Inertia Result. return(Inertia.Render(componentName, data)); }
public async Task <IActionResult> Login(string returnUrl = null) { returnUrl ??= Url.Content("~/"); // Clear the existing external cookie to ensure a clean login process await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme); return(Inertia.Render(_componentResolver.ResolveComponent(nameof(Login)), new { returnUrl })); }
public IActionResult Index(string redirectComponent) { var component = redirectComponent.IsEmpty() ? "Home/Index" : redirectComponent; var model = new Page { Component = component, Url = component }; return(!IsInertiaRequest ? (IActionResult)View(model) : Inertia.Render("Home/Index", new { })); }
public IActionResult Index() { var rng = new Random(); var forecast = Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateTime.Now.AddDays(index), TemperatureC = rng.Next(-20, 55), Summary = Summaries[rng.Next(Summaries.Length)] }) .ToArray(); //your js component file name. var componentName = "Forecast"; //return whatever you want. var data = new { forecast }; //return Inertia Result. return(Inertia.Render(componentName, data)); }