Castle MonoRailベースのサイトに、追加フォームと編集フォームを含むいくつかの追加を書いています。追加フォームは正常に機能し、POSTを使用しますが、編集フォームはGETを使用します。私が見ることができる唯一の大きな違いは、クエリ文字列で編集されているオブジェクトのIDを使用してeditメソッドが呼び出されることです。編集フォームで送信ボタンを押すと、渡される引数はこのオブジェクトIDのみです。編集フォームのコードは次のとおりです。
<form action="edit.ashx" method="post">
<h3>Coupon Description</h3>
<textarea name="comments" width="200">$comments</textarea>
<br/><br/>
<h3>Coupon Actions</h3>
<br/>
<div>Give Stories</div>
<ul class="checklist" style="overflow:auto;height:144px;width:100%">
#foreach ($story in $stories.Values)
<li>
<label>
#set ($associated = "")
#foreach($storyId in $storyIds)
#if($story.Id == $storyId)
#set($associated = " checked='true'")
#end
#end
<input type="checkbox" name="chk_${story.Id}" id="chk_${story.Id}" value="true" class="checkbox" $associated/>
$story.Name
</label>
</li>
#end
</ul>
<br/><br/>
<div>Give Credit Amount</div>
<input type="text" name="credit" value="$credit" />
<br/><br/>
<h3>Coupon Uses</h3>
<input type="checkbox" name="multi" #if($multi) checked="true" #end /> Multi-Use Coupon?<br/><br/>
<b>OR</b>
<br/>
<br/>
Number of Uses per Coupon: <input type="text" name="uses" value="$uses" />
<br/>
<input type="submit" name="Save" />
</form>
これと追加フォームの違いは、関連付けに関係する速度と、PropertyBagからの入力の値です。
コントローラでこれを処理するメソッドは、次のように開始されます。
public void Edit(int id)
{
Coupon coupon = Coupon.GetRepository(User.Site.Id).FindById(id).Value;
if(coupon == null) {
RedirectToReferrer();
return;
}
IFutureQueryOfList<Story> stories = Story.GetRepository(User.Site.Id).OnlyReturnEnabled().FindAll("Name", true);
if (Params["Save"] == null)
{
...
}
}
確実に呼び出されますが、Params ["Save"]のブレークポイントにより、HttpMethodが "GET"であり、渡される引数(フォームとリクエスト)はオブジェクトIDと追加のHTTPヘッダーのみであることがわかります。
結局のところ、私はMonoRailにあまり精通しておらず、これは私に代わって愚かな間違いかもしれませんが、問題が解決した場合は馬鹿にされていただければ幸いです。:)
ありがとう