#1 2019-12-30 15:00:35

martin.suer
Member
Registered: 2013-12-15
Posts: 76

MVCServer Sample (30) - Redirection issue

Hi,

from the documentation I understand, that I can just append a 'json' to a url (as the last part before any parameters) and then just get the data context instead of the processed mustache template.
This basically works great but there's a problem with redirecting in this case.

Using the Sample "30 - MVC Server" I can call .../blog/login?LogonName=usrname&PlainPassword=abcd and get redirected to .../blog/default - which is correct.
However, if I call .../blog/login/json?LogonName=usrname&PlainPassword=abcd then I get redirected to .../blog/login/Default which doesn't exist and causes an Error 400. Somehow rewriting the url doesn't work if "json" is appended ...

If in this second case the redirection would redirect to .../blog/Default/json it would be possible to write an mvc application which uses html templates for creating html and at the same time I could write a fat client in some client language or a javascript client which makes use of the .../json urls. That way I would only have one server which can be used by different types of client easily.

Currently I can't do that because the automatic TMVCAction redirection doesn't work for urls which have the .../json appended.

Martin

Offline

#2 2019-12-31 10:20:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: MVCServer Sample (30) - Redirection issue

I don't get why you would need redirection with the /json trick.

Offline

#3 2019-12-31 14:06:19

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: MVCServer Sample (30) - Redirection issue

I think it would be better to create a separate endpoint (service), on the same server.

Example:
/blog/... to pages (HTML)
/api/.. to services (JSON)

Offline

#4 2019-12-31 14:47:59

martin.suer
Member
Registered: 2013-12-15
Posts: 76

Re: MVCServer Sample (30) - Redirection issue

Yes, that's one way. My initial idea was to have a MVC web application (just pure html, created with mustache templates) which at the same time could be used e.g. by a single page javascript web app which just calls the same urls but appends json to the existing urls. That would work if the redirection also were to work with the .../json urls.
If that redirection doesn't work, I need two different implementations of a server method for basically the same thing (e.g. in the case of the Login method of the example). Maybe that's a better way.

Offline

Board footer

Powered by FluxBB