viewresult

ASP.NET MVC - HybridViewResult (ViewResult /PartialViewResult)

别说谁变了你拦得住时间么 提交于 2019-12-21 20:22:16
问题 Is it possible to build a hybrid ViewResult that returns in depedency of an AjaxRequest or HttpRequest a PartialViewResult or ViewResult ? IsAjaxRequest --> return PartialViewResult !IsAjaxRequest --> return ViewResult As far as I know my HybridViewResult should derive from ViewResultBase. But how to implement the FindView method? 回答1: Try: public class HybridViewResult : ActionResult { public string ViewName { get; set; } public HybridViewResult () { } public HybridViewResult (string

Bestpractice DI with ASP.NET MVC and StructureMap - How to inject dependencies in an ActionResult

杀马特。学长 韩版系。学妹 提交于 2019-12-07 13:03:10
问题 I edited my whole question, so do not wonder :) Well, I want to have an ActionResult that takes domain model data and some additional parameters, i.e page index and page size for paging a list. It decide itself if it returns a PartialViewResult or a ViewResult depending on the kind of web request (ajax request or not). The reffered data shall be mapped automatically by using an IMappingService, which is responsible for transforming any domain model data into a view model. The MappingService

Must ASP.NET MVC Controller Methods Return ActionResult?

丶灬走出姿态 提交于 2019-11-27 11:32:22
Being new to ASP.NET MVC, I've been wondering about the signature of Controller methods. In all the examples I've seen, they always seem to return ActionResult, even if they actually return a ViewResult instance or similar. Here's a commonly seen example: public ActionResult Index() { return this.View(); } In such a case, wouldn't it make more sense to declare the method as public ViewResult Index() , and get stronger type support? Experimentation indicates that this works, so it seems possible. I do realize that there may be situations where the polymorphism is desired (e.g. if you want to

Must ASP.NET MVC Controller Methods Return ActionResult?

扶醉桌前 提交于 2019-11-26 15:37:02
问题 Being new to ASP.NET MVC, I've been wondering about the signature of Controller methods. In all the examples I've seen, they always seem to return ActionResult, even if they actually return a ViewResult instance or similar. Here's a commonly seen example: public ActionResult Index() { return this.View(); } In such a case, wouldn't it make more sense to declare the method as public ViewResult Index() , and get stronger type support? Experimentation indicates that this works, so it seems