为什么要使用AppHarbor插件?(Why use AppHarbor addons?)
当我可以直接从提供商处获得帐户并获得额外的好处(如每个帐户的多个用户或项目)时,为什么我应该使用AppHarbor插件? 我知道每个应用程序都有插件集中配置,但这也意味着你必须通过AppHarbor。
此外,AppHarbor在一些提供商(特别是Airbrake)的网站上添加了标题,这些设计器破坏了设计(看起来不合适并且具有巨大的利润)。 在一些插件上,定价比插件定价灵活得多(同样,Airbrake就是一个很好的例子 - 不知道这些计划提供的是什么!)。
Why should I use AppHarbor addons when I can get an account directly from the provider and have additional benefits (like multiple users or projects per account)? I know having addons per application centralizes configuration but it also means you have to go through AppHarbor.
In addition AppHarbor adds their header on the website of some providers (notably Airbrake), which ruins the design (looks out of place and has massive margins). On some addons pricing is much more flexible than the addon pricing (again, Airbrake is a good example - no idea what those plans offer!).
原文:https://stackoverflow.com/questions/11126734
最满意答案
模型绑定就是这样,绑定模型。 如果模型不存在,它将返回null或Null对象。 然后控制器可以决定如何处理模型。 如果它为null,则抛出。
但是,如果您看到相同的代码行出现,那么封装该代码是一个好主意。 一种选择是使用ActionFilter。 模型绑定器创建对象,如果模型为null,则操作过滤器可以将响应代码设置为404。
在这种情况下,您的控制器只需要担心“快乐路径”。 这就是模型的存在。
Model binding does just that, binds the model. if the model doesn't exist it would return either null or a Null Object. The controller could then decide what to do with the model. If it's null, throw.
however if you you see the same lines of code appearing than it's a good idea to encapsulate that code. One option would be to use an ActionFilter. the model binder creates the objects and the action filter can set the response code to 404 if the model is null.
in this scenario your controller only needs to worry about the "happy path". That is the model exists.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
在ASP.NET MVC 1.0中使用ModelBinder处理无效值(Handling invalid values with ModelBinder in ASP.NET MVC 1.0)[2023-08-12]
这对我来说会造成一些困难,因为现在我无法看到用户是否实际输入了0,或者这是否是由无效输入引起的。 是的你可以。 查看ModelState。 This causes some difficulty for me ofcourse, because now I can't see if the user actually entered 0, or if this was caused by invalid input. Yes you can. Look in the ModelState. -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
ASP.NET MVC 3引入了HttpNotFoundResult操作结果,它应该优先使用http状态代码手动抛出异常。 这也可以通过控制器上的Controller.HttpNotFound方法返回: public ActionResult MyControllerAction() { ... if (someNotFoundCondition) { return HttpNotFound(); } } 在MVC 3之前,您必须执行以下操作: throw new ...
-
Servlet API提供了发送404或任何其他HTTP状态代码的方法。 这是HttpServletResponse的sendError方法: public void doGet(HttpServletRequest request, HttpServletResponse response) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } The Servlet API gives you a method to send a ...
-
throw; 重新启动原始异常并保留其原始堆栈跟踪。 throw ex; 抛出原始异常,但重置堆栈跟踪,摧毁所有堆栈跟踪信息,直到您的catch块。 从来没有写过 throw new Exception(ex.Message); 更糟糕 它创建一个全新的Exception实例,丢失Exception的原始堆栈跟踪以及其类型。 (例如, IOException )。 另外,一些例外还有其他信息(例如, ArgumentException.ParamName )。 throw new Exception(ex. ...
-
我使用自定义模型绑定器的原因有几个 这是我过去使用过的一个例子 http://www.codeproject.com/Articles/519301/Automatic-Encryption-of-Secure-Form-Field-Data 另一种情况是,如果你想绑定到接口并对结核进行后期绑定,Mvc不支持开箱即用,你可以写一个模型绑定器来做到这一点 There are a few reasons I have used custom model binders here is an example of ...
-
翁德瑞是对的。 只要链接它们: IHttpActionResult Foo([FromBody][ModelBinder]SomeModel model) Ondrej is right. Just chain them: IHttpActionResult Foo([FromBody][ModelBinder]SomeModel model)
-
模型绑定就是这样,绑定模型。 如果模型不存在,它将返回null或Null对象。 然后控制器可以决定如何处理模型。 如果它为null,则抛出。 但是,如果您看到相同的代码行出现,那么封装该代码是一个好主意。 一种选择是使用ActionFilter。 模型绑定器创建对象,如果模型为null,则操作过滤器可以将响应代码设置为404。 在这种情况下,您的控制器只需要担心“快乐路径”。 这就是模型的存在。 Model binding does just that, binds the model. if the mo ...
-
你可以使用HttpClient ,它不会在404上抛出异常: HttpClient c = new HttpClient(); var resp = await c.SendAsync(new HttpRequestMessage(HttpMethod.Head, "http://www.google.com/abcde")); bool ok = resp.StatusCode == HttpStatusCode.OK; You can use HttpClient, it doesn't thro ...