Tag: t4mvc

ASP.NET MVC3如何直接从控制器引用视图

在我的控制器中,我想指定一个不同于默认值的视图。 像这样 : public ActionResult EditSurvey(Int32 id) { Survey survey = _entities.Surveys.Single(s => s.Id == id); return View(“Survey”,survey); } 但是我没有将视图指定为字符串(“Survey”),而是想直接引用它,所以如果我决定稍后更改我的视图名称,则不必手动更改此字符串。 所以我正在寻找这样的东西: public ActionResult EditSurvey(Int32 id) { Survey survey = _entities.Surveys.Single(s => s.Id == id); return View(Views.Admin.Survey,survey); }

强类型T4MVC Action / ActionLink

我已经使用T4MVC (仅供参考:v2.6.62)很长一段时间了,我一直在慢慢地将代码转移到这种工作方式(减少对魔术字符串的依赖)。 但是我不得不停下来,因为由于某种原因,T4MVC无法将对象转换为URL,并且似乎只能处理原始类型(int / string / etc)。 这是一个例子: 路线分解: /MyController/MyAction/{Number}/{SomeText} 类: namespace MyNamespace { public class MyClass { public int Number { get; set; } public string SomeText { get; set; } } } 控制器: public class MyController { public virtual ActionResult MyAction(MyClass myClass) { return View(); } } 视图: 最终结果如下: /MyController/MyAction?myClass=MyNamespace.MyClass 并不是 /MyController/MyAction/1/ABC 还有其他人有这个问题吗? […]

AssemblyBinding BindingRedirect不适用于带有T4MVCExtensions的MVC4应用程序

我们有一个使用T4MVC的大型.NET Web应用程序MVC3。 我们最近将它升级到了MVC4,除了T4MVCExtensions(来自NuGet的版本3.6.5)仍然依赖于System.Web.Mvc版本3之外一切都很好。你应该在web.config中设置的运行时依赖项应该是应该的重定向程序集绑定,但它们似乎不是。 发生以下exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception […]