#1 2014-11-11 06:30:06

Pyjama
Member
Registered: 2014-07-07
Posts: 9

MVC form action question

Hello ab,

I did a form like:

<form action="Account?View=Something" method="post">
	<input type="text" name="SomethingElse" value="Anything"></input>
	<span>SomethingElse</span>
	<input type="submit" name="submit" value="Submit"></input>
</form>

But it don't works.
If I delete the action parameters, so there is only "Account", it works.

Why I could not give the action any other parameters? The variables should be

View = Something
SomethingElse = Anything
submit = Submit

Offline

#2 2014-11-11 10:24:37

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

Re: MVC form action question

You are not using parameters encoding as expected by the HTTP standard.
If you use method="post" then the parameters are encoded as HTTP message body, not at url level.
So you can't mix URI-encoded parameters and  method="post".

Two solutions:
- If you want to add parameters at URI level, use method="get" instead.
- If you want to add parameters with method="post", use hidden fields.

Offline

#3 2014-11-12 14:54:16

Pyjama
Member
Registered: 2014-07-07
Posts: 9

Re: MVC form action question

Thank you for your answere.

What is about TGUID?

If I want to add a TGUID over the GET-method I do not get the variable.

Does this not support TGUID in a GET method or URI? Or this happens because there are curly brackets and he doesn't know what to do?

Regards

Offline

#4 2014-11-12 16:37:45

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

Re: MVC form action question

You can transmit the GUID as a string.

Offline

#5 2014-11-13 14:28:23

Pyjama
Member
Registered: 2014-07-07
Posts: 9

Re: MVC form action question

But I .. think it dont works correctly.

If I want to go to

Default?View=MyPage&GuID={B387D2CE-XXXX-XXXX-XXXX-B7AAE73D5E27}

There is a variable View (correctly) and a variable GuID (nothing).

In parameters I called it this way:

const View, GuID : RawUTF8;

Gives me:

View = 'MyPage';
GuID = ''; // nothing

How can I solve this?

Edit:
I tried it without brackets and it worked. Is it possible to get it with the brackets?

Last edited by Pyjama (2014-11-13 14:38:10)

Offline

#6 2014-11-13 15:33:01

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

Re: MVC form action question

You are playing with the command line, which is something buggy, depending on your browser.
URI is always encoded, so what you write is not what is transmitted...

Did you try with quotes?

Default?View=MyPage&GuID="{B387D2CE-XXXX-XXXX-XXXX-B7AAE73D5E27}"

Offline

#7 2014-11-14 06:32:17

Pyjama
Member
Registered: 2014-07-07
Posts: 9

Re: MVC form action question

ab wrote:

Did you try with quotes?

Default?View=MyPage&GuID="{B387D2CE-XXXX-XXXX-XXXX-B7AAE73D5E27}"

I tried and I get this one:

GuID = '"{B387D2CE-XXXX-XXXX-XXXX-B7AAE73D5E27}"'

with quotes. I don't want to cut the String. You know another solution?

Last edited by Pyjama (2014-11-14 06:32:55)

Offline

Board footer

Powered by FluxBB