Render a Form view to collect data to post to a resource creation service

In traditional server-side MVC a Create resource action usually consists of two requests, a GET which returns a form to be completed by the user and a POST which accepts the FormData.

In ASP.NET MVC the controller actions would look like this:

public ActionResult Create() {}

public ActionResult Create(X x) {}

In SS I have a CreateX service which fulfils the POST part. What’s the best way of returning the form in the first place?

I thought about creating a NewX service, it wouldn’t actually return any data but would render the form view. Alternatively as no-data is involved maybe a content page would be a better choice? Though that doesn’t feel quite right either.

I personally don’t use a Service for most pages and would just render a No Controller Content Page for this. But then again my preference is to go with API-first development where I’d post Form’s using ajax which I find more flexible, responsive + has less friction.

But if you wanted to you can also have an an empty Service, i.e

object Any(GetX request) => request;

And render a ViewPage at /Views/GetX.cshtml

1 Like