示例#1
0
 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" }));
 }
示例#2
0
        public IActionResult Index()
        {
            //return whatever you want.
            var data = new { Id = 1 };

            //return Inertia Result.
            return(Inertia.Render(_componentResolver.ResolveComponent(nameof(Index)), data));
        }
示例#3
0
        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);
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#6
0
        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
            }));
        }
示例#7
0
        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 { }));
        }
示例#8
0
        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));
        }