私のウェブアプリで
webApp
\Views
\Views\School
\Views\School\School.cshtml
\Views\School\Schools.cshtml
Request クラスと Response クラスでは:
[Route("/v1/school", Verbs = "POST")]
[DefaultView("School")]
public class SchoolAddRequest : School, IReturn<SchoolResponse>
{
}
public class SchoolResponse
{
public School School { get; set; }
public SchoolResponse()
{
ResponseStatus = new ResponseStatus();
Schools = new List<School>();
}
public List<School> Schools { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
SchoolService.cs で:
[DefaultView("School")]
public class SchoolService: Service
{
public SchoolResponse Post(SchoolAddRequest request)
{
var sch = new School {Id = "10"};
return new SchoolResponse {School = sch, ResponseStatus = new ResponseStatus()};
}
}
school.cshtml で:
@inherits ViewPage<Test.Core.Services.SchoolResponse>
@{
Layout = "_Layout";
}
<form action="/v1/School" method="POST">
@Html.Label("Name: ") @Html.TextBox("Name")
@Html.Label("Address: ") @Html.TextBox("Address")
<button type="submit">Save</button>
</form>
@if (@Model.School != null)
{
@Html.Label("ID: ") @Model.School.Id
}
ブラウザ上:
これは機能するはずですが、機能しません。空白のページが表示されます
http://test/school/
これは機能します:
http://test/views/school/
「保存」ボタンを押すと、必要な応答が返されますが、ブラウザーの URL は次のとおりです。
http://test/v1/School
私はそれが次のようになることを期待していました:
http://test/School
URLを正しく機能させるにはどうすればよいですか? http://test/School
リクエストとレスポンスではないはず
です。