Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Submitting a form to a service and handling server-side validation on an HTML client


In this recipe, we will look at an example of submitting an HTML form to an existing ServiceStack service. We will utilize some JavaScript that the ServiceStack server hosts, which helps us bind data from a form.

Getting ready

If you are starting with a new project, please go to the section Creating a ServiceStack solution with Visual Studio and NuGet in Appendix A, Getting Started, to help you get set up.

We will be using some existing services from the PlacesToVisit examples with some modification to show the use of validation.

How to do it…

  1. Within the Configure method of your application host, register dependencies for the use of Sqlite and the repository interface from the PlacesToVisit domain, as follows:

    container.RegisterAutoWired<PlacesToVisitAppSettings>();
    var appSettings = 
      container.Resolve<PlacesToVisitAppSettings>();
    var dbFactory = new OrmLiteConnectionFactory(appSettings.Get("sqlLiteConnectionString...