使用 OpenRasta 和 Web 表单实现简单的 CRUD
我被要求研究 OpenRasta 作为工作中 MVC ASP.NET 的替代方案,作为起点,我尝试从 MVC ASP.NET 网站复制电影教程。
我真的很喜欢 OpenRasta 的 ReST 风格,到目前为止已经有了一个简单的数据库和一个基于 ID 的 GET 处理程序,其形式为
ResourceSpace.Has.ResourcesOfType<Movie>()
.AtUri("/movie/{id}")
.HandledBy<MovieHandler>()
.RenderedByAspx("~/Views/MovieView.aspx");
我知道使用 POST 和 DELETE 将允许我创建/更新和删除我的项目数据库,但不幸的是我对如何处理视图感到困惑。
在 OpenRasta 文档中,它说:
When you use an aspx page as a view in OpenRasta, you essentially create a template to
generate content. As such, postbacks and events are not supported.
我在这里可能真的很愚蠢,但是我能够按照 OpenRasta 要求的方式从 ASP.NET 页面进行 POST 和 DELETE 吗?我正在使用代码隐藏页面,但这不是我所关注的。
我对 ASP.NET 不太熟悉(已经很久没有做过任何事情了),所以我可能会错过一些明显的东西,但我真的很感激一些正确方向的指导。
I've been asked to look into OpenRasta as an alternative to MVC ASP.NET at work, and as a starting point I'm trying to replicate the Movies tutorial from the MVC ASP.NET website.
I really like the ReST style of OpenRasta, and so far have got a simple database and a handler for GET based by ID, in the form of
ResourceSpace.Has.ResourcesOfType<Movie>()
.AtUri("/movie/{id}")
.HandledBy<MovieHandler>()
.RenderedByAspx("~/Views/MovieView.aspx");
I understand that use of POST and DELETE would allow me to create/update and delete items from my database, but unfortunately I'm stumped on how to do the views.
In the OpenRasta documentation it says:
When you use an aspx page as a view in OpenRasta, you essentially create a template to
generate content. As such, postbacks and events are not supported.
I might be being really dumb here, but would I be able to POST and DELETE from an ASP.NET page in the manner required by OpenRasta? I'm using a code-behind page, but that's not something I'm fixated upon.
I'm not that familiar with ASP.NET (haven't done any for ages), so I may be missing something obvious, but would really appreciate some pointers in the right direction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这意味着不支持 asp.net webforms 中的回发模型(也称为 asp.net webforms 基础结构创建一个大型表单标记以将 asp.net 特定数据连续回发到页面的行为),因此任何事件您可能习惯在 webforms 上使用控件将无法工作。
如果您习惯了 MVC 风格的交互,您就会知道如何使用表单标签,这样您就可以像往常一样创建新电影。
另一种方法是使用 Webforms 引擎在代码中完成此操作
,并且您的处理程序代码
代码在我的脑海中进行编译,并且在放入编译器之前可能需要进行现实检查。
请注意,如果可以的话,放弃 Webforms 引擎可能是个好主意,有更好的替代品(razor、spark,无论您决定插入什么)。
What this means is that the postback model in asp.net webforms (aka the behavior by which the asp.net webforms infrastructure creates one massive form tag to post back asp.net specific data to a page continuously) is not supported, so any events you may be used to use on webforms controls will not work.
If you're used to MVC-styled interactions, you know how to use the form tag so you do as usual to create a new movie.
The alternative is to do it in code using the webforms engine
And your handler code
Code compiles in my head and may need a reality check before being put in a compiler.
Note that it's probably a good idea to move away from the webforms engine if you can, there are better alternatives (razor, spark, whatever you may decide to plug in).