t4mvc

t4mvc : Cannot inherit a controller class which has no default constructor?

谁说胖子不能爱 提交于 2019-12-01 14:41:09
问题 I am using T4MVC with MVC2. I have the following building blocks: A simple entity interface which defines that every POCO entity must have a long Id property: public interface IEntity { public long Id; } A simple POCO class which implements the IEntity interface and has some string properties: public class CD : IEntity { public long Id { get; set; } public long Name { get; set; } } A base controller: public abstract class EntityController<T> : Controller where T : class, global::IEntity {

Create a T4MVC ActionLink with url fragment

放肆的年华 提交于 2019-11-29 13:22:10
Is there a way to create a strongly typed T4MVC ActionLink with a hash/pound/fragment in it? For example, here is the link I'd like to create: <a href="/Home/Index#food">Feed me</a> But there's no extension to the T4MVC object that can do this. <%= Html.ActionLink("Feed me", T4MVC.Home.Index()) %> So, what I end up having to do is create an action, and then embed it that way: <a href="<%= Url.Action(T4MVC.Home.Index()) %>"#food>Feed me</a> This isn't very desirable. Anyone have any ideas/suggestions? Thanks in advance This kind of approach is the only one i can think of that feels (to me)

AssemblyBinding BindingRedirect not working for MVC4 app with T4MVCExtensions

陌路散爱 提交于 2019-11-29 07:30:15
We have a large .NET web application that was MVC3, using T4MVC. We recently upgraded it to MVC4, and all is good except for T4MVCExtensions (version 3.6.5 from NuGet) is still dependent on System.Web.Mvc version 3. The runtime dependencies that you're supposed to setup in the web.config SHOULD be redirecting the assembly bindings, but they don't seem to be. The following exception occurs: 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.

Cannot get T4MVC to work with VS2010 and ASP.NET MVC 2

让人想犯罪 __ 提交于 2019-11-29 06:51:31
I'm trying to add the T4MVC templates to my project, but I'm experiencing some problems. I went to Codeplex and downloaded the latest version of T4MVC , and according to the instructions I just copied the two files T4MVC.tt and T4MVC.Settings.t4 into the root of my web application. Immediately, I got the following errors: From T4MVC.cs (generated file): A namespace cannot directly contain members such as fields or methods From T4MVC.tt (the code generating template): Compiling transformation: The type or namespace name 'ITextTemplatingEngineHost' could not be found (are you missing a using

razor syntax with errors compiles when it should not compile

谁说我不能喝 提交于 2019-11-28 23:12:51
So I an into an error at runtime with my asp.net mvc3 app, when I checked the code I see that it has a red line on it, the error list says there is no such function defined but it will still compile fine . The error shows up only at runtime? I'm using T4MVC and I was hoping it would help me dodge problems like this!? Is this by design or am I doing something wrong here? The code above should NOT compile because there is no such method there! It fails at runtime : This kinda of thing happens a lot, not just for un defined methods, but even variables, etc. Martin Buberl This is by design. The

T4MVC @Url.Action(MVC.Controller.Action()) Renders “?Area=” Parameter in QueryString

时光总嘲笑我的痴心妄想 提交于 2019-11-28 20:27:35
I am rendering a menu from a Partial Action directly to the layout, using: @Html.Action(MVC.Menu.Index()) This action, determines which Menu partial to render. For instance, a public menu partial. Within these partials, I am also using T4MVC to render the links: <ul id="navHolder"> <li class="level1"> <ul class="mainMenu"> <li><b>@Html.ActionLink("Welcome", MVC.Home.Index())</b> ... For some reason, the Urls rendered by T4MVC include "?Area=" at the end: <ul id="navHolder"> <li class="level1"> <ul class="mainMenu"> <li><b><a href="/home/index?Area=">Welcome</a></b> ... I have NO areas in my

How can I add a hash fragment to T4MVC route dictionary ActionResult?

ε祈祈猫儿з 提交于 2019-11-28 11:38:22
I have an extension method that returns an ActionResult (simplified for demonstration purposes): public static ActionResult GetTestActionResult(this HtmlHelper htmlHelper, int productId) { return MVC.Products.Details(productId); } I'm using this in an Html.ActionLink: @Html.ActionLink("Product Details", Html.GetTestActionResult(Model.ProductId), new { @class = "button blue" }); I'm using a custom jQuery plugin for tabs, that uses these hash fragments for navigation. I want to add the tab which I want to open, by tagging the hash fragment onto the end of the URL. Html.ActionLink does have an

Create a T4MVC ActionLink with url fragment

六月ゝ 毕业季﹏ 提交于 2019-11-28 07:15:21
问题 Is there a way to create a strongly typed T4MVC ActionLink with a hash/pound/fragment in it? For example, here is the link I'd like to create: <a href="/Home/Index#food">Feed me</a> But there's no extension to the T4MVC object that can do this. <%= Html.ActionLink("Feed me", T4MVC.Home.Index()) %> So, what I end up having to do is create an action, and then embed it that way: <a href="<%= Url.Action(T4MVC.Home.Index()) %>"#food>Feed me</a> This isn't very desirable. Anyone have any ideas

Using T4MVC with build script

懵懂的女人 提交于 2019-11-27 19:04:08
问题 Has anyone gotten T4MVC to run as part of a build script ? Preferably a NAnt build script. I'd like to not have to check in the generated files and just have the build server create them as part of the build, but T4MVC will only run inside of Visual Studio. I've tried: http://devtalk.dk/2010/03/11/How+To+Run+T4MVC+On+Build.aspx http://otac0n.com/blog/2010/12/23/Pain-Free-T4MVC.aspx Has anyone successfully gotten a solution to work ? 回答1: I don't think you'll be able to make this work. T4MVC

razor syntax with errors compiles when it should not compile

心已入冬 提交于 2019-11-27 14:38:18
问题 So I an into an error at runtime with my asp.net mvc3 app, when I checked the code I see that it has a red line on it, the error list says there is no such function defined but it will still compile fine . The error shows up only at runtime? I'm using T4MVC and I was hoping it would help me dodge problems like this!? Is this by design or am I doing something wrong here? The code above should NOT compile because there is no such method there! It fails at runtime : This kinda of thing happens a