Am I missing a reference or something?
I have a reference to System.Web.Mvc 4.0x
But whenever I try this
#Html.LabelFor(x=>Model.yadda, new {id="_lblYadda"});
I get nothing I can't even get it to compile. I only have a reference to
#Html.Label("Yadda", "Yadda yadda");
I spent like 5 minutes looking, I know it's simple so.. help please!
WebConfig namespaces are:
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
Found my issue:
I noticed that the project that works references System.Web.Mvc.Html and the one that I'm using for #Html.Label() references System.Web.WebPages.dll
I removed the reference to System.Web.WebPages.dll and now it works with all the extensions.
System.Web.WebPages.dll is crap... The End... THanks
Related
I got VS 2015 and MVC, i get this red stuff in several projects. What can be the cause. Views is the only problem, works fine in code behind.
add below in web.config(Inside View folder web.config as well outside web.config)
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
</namespaces>
I used to use visual studio 2012 and in an area telerik was configured and worked correctly.
after changing visual studio to 2013 this error occurred after each page is rendering.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Line 50: #(Html.Telerik().StyleSheetRegistrar())
web.config structure for this area view is:
<system.web.webPages.razor>
</system.web.webPages.razor>
i don't wanna change telerik to kendo.ui
what's the problem?
web.config of the view
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization" />
<add namespace="Bazidan.MVC.UI" />
<add namespace="Telerik.Web.Mvc.UI"/>
<add namespace="MvcSiteMapProvider.Web.Html" />
<add namespace="MvcSiteMapProvider.Web.Html.Models" />
</namespaces>
I have extended HtmlHelper, then when trying to use it in partial view it doesn't show in intellisense, I have added the namespace to the web.config. the only way to get it to work was to add a using statement to the partial view. Am I missing something? I would prefer not to add using statements to every view using it.
Ensure that you are editing the config file in your Views directory.
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Your.Namespace.Goes.Here" />
</namespaces>
</pages>
</system.web.webPages.razor>
Also, sometimes you might need to close and reopen the .cshtml file or even restart Visual Studio.
This may be a similar question, but since the other is not answered I thought I'd ask here. I have a mvc 4 application works fine on my local but when I deployed to my web host I got the following error
ambiguous reference between 'System.Web.WebPages.Scripts' and 'System.Web.Optimization.Scripts'
on every #Scripts.Render("")
Though #Styles.Render("") is fine.
What's the easiest fix for this, I should not need to append "System.Web.Optimization" in front of every #Scripts.
Thanks!
Edit: I tried commenting out System.Web.WebPages in my web.config, still not working, here is my web.config
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<!--<add namespace="System.Web.WebPages" />-->
</namespaces>
</pages>
This problem has been resolved by the web host by doing the following:
Removed MVC 4 reference from GAC (since it is meant to be bin deployed) and also re-installed ASP.NET Web Pages 2.
Basically System.Web.WebPages.Scripts is not in WebPages namespace anymore for webpages2, reinstalling it seems to have helped.
Hope this can help others.
Ray.
I have an existing asp.net web application which I need to convert to mvc3.
As soon as I add the below my project's web.config, the project stops working I am using IIS 5. I guess I have missed something in IIS, please advise
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
First confirm if any MVC3 project works with IIS5 the way you have it configured, you may need to setup the wildcard rule and uncheck verify if file exsists. Once you have done this what I do is just create a new MVC3 project that is empty and move over my stuff from the old project to the new project. That is the least hassel free way of doing it. Keep the namespace of the solution the same so you don't have to deal with namespace mismatch issues.