I think it is just because razor compiler has no idea what type TModel should be.
Up vote 0 down vote favorite share g+ share fb share tw.
I have a strongly-typed view with a @model declaration: @model MyViewModel When using extension methods like this in my Razor views: @Html. TextBoxFor(m => m. Foo) Visual Studio shows errors like this: The type arguments for method 'System.Web.Mvc.Html.InputExtensions.
TextBoxFor(System.Web.Mvc. HtmlHelper, System.Linq.Expressions. Expression>)' cannot be inferred from the usage.
Try specifying the type arguments explicitly. These are only errors shown for the editor window; the view renders just fine at runtime. Does this happen for everyone, or is there something I can do to make the Razor editor work better?
Visual-studio-2010 asp. Net-mvc-3 c#-4.0 razor type-inference link|improve this question edited Dec 1 '11 at 20:53 asked Dec 1 '11 at 19:27Jacob20.3k11761 95% accept rate.
– Mihalis Bagos Dec 1 '11 at 19:47 @mnemosyn, we don't have a custom view page factory. – Jacob Dec 1 '11 at 20:52 @MihalisBagos, I've added my @model declaration to the post. The razor view really only has usings, the model declaration, and markup like the snippet I posted.
– Jacob Dec 1 '11 at 20:54 Does it happen for views in both the root and in areas? You could try using the fully qualified name in the @model declaration. – Charlino Dec 1 '11 at 22:03.
I think it is just because razor compiler has no idea what type TModel should be. I get the same errors and just ignore them because, it works so I am happy inside. But you could possibly try something like this, although having written it I think it's retarded and probably epicly useless but maybe someone else can shed some light on why it is retarded and the actual solution to avoiding these errors.
Public class SomeBlah { public Blah blahs { get; set; } } public class Blah { public string Rawr { get; set; } } @model SomeBlah @Html. TextBoxFor(s => s. Rawr).
I hope to be able to avoid explicit types like this. Hopefully someone has figured this out. – Jacob Dec 1 '11 at 20:56 I think therein lies the problem, razor likes explicit types =P – Hazza Dec 1 '11 at 21:33.
Make sure that the web. Config file in your web project has the correct namespaces imported. There's a chance your deployed website is using a different web.
Config than the one visual studio is using to parse the razor file.
Thanks to this answer, I found the solution. In my web. Config, once I specified a targetFramework attribute in my system.
Web/compilation config section, all of those nasty warnings disappeared. Previously, no targetFramework was specified. Strangely, Visual Studio doesn't just use the target framework of your project.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.