Skip to content
This repository was archived by the owner on Aug 10, 2019. It is now read-only.

DustinKingen/SpaServices

Repository files navigation

Kingensoft Spa Services - Helpers for building single-page applications on ASP.NET MVC Core.

Build status

Release Notes

Located at dustinkingen.github.io/SpaServices

Features

Kingensoft.AspNetCore.SpaServices.TagHelpers is a NuGet library that contains tag helpers for building single-page applications on ASP.NET Core.

Embed application state into a view or page.

<application-state initial-state="@YourState">

Example usage:

Index.cshtml

@page
@model IndexModel

<form id="app">
    {{ message }}
</form>

@section Scripts
{
    <application-state initial-state="@Model">

    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: window.__INITIAL_STATE__
        });
    </script>
}

Index.cshtml.cs

// Opt in to capture members to output
[JsonObject(MemberSerialization.OptIn)]
public class IndexModel : PageModel
{
    [JsonProperty]
    public string Message { get; set; }
    
    public void OnGet()
    {
        Message = "Hello Vue!";
    }
}

Limitations and caveats

ApplicationStateTagHelper is useful for smaller application (e.g. Razor Pages). Nesting application state (partial views) is not currently supported.

Do you have a comprehensive list of examples?

Check out the samples.

About

Helpers for building single-page applications on ASP.NET Core.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors