I downloaded MVC2 Futures and referenced it to my current MVC2 Project. However, if I want to call an HtmlHelper from MVC2 Futures I need to <%# Import Namespace="Microsoft.Web.Mvc" %>
So I decided to add it on my Web.Config:
<pages>
<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="Microsoft.Web.Mvc" />
<add namespace="Xpedite.Mvc.Html" />
</namespaces>
</pages>
but, this caused me errors. Could this assemblies co-exist? If yes, How?
I'm pretty sure you need the MVC3 Futures pack:
http://aspnet.codeplex.com/releases/view/54306
The MVC2 Future was made to work against MVC1. I had the same issue and upgrading to the next futures release solved it for me.
Related
In my ASP.NET MVC 5 Application I have all my models in the namespace MyApp.Models. To use the model inside my view, e.g. to tell the view which model he should use with #model UserLoginModel, I have to import the namespace with using MyApp.Models.
Thats not a big deal but I would prefer it to include this namespace automatically in every of my views to avoid redundant importing in every view. I found out that the web.config file in my views-folder seems to be right for this job
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.Optimization"/>
<add namespace="MyApp" />
<add namespace="MyApp.Models"/>
</namespaces>
</pages>
But its not working. All of this was pre-generated by Visual Studio. I only added the <add namespace="MyApp.Models"/> for my models.
On SO I found a similar question like my but the asker only say that it should work by using the Views/web.config file as I tried and the answears follow his question which is specified to the new beta of ASP.NET MVC 6. But I'm using MVC 5.1.2 and cant get make this work, he can't find the view without including the namespace with #using in the view.
I am using Visual Studio 2013 Web Express. In my ASP.NET MVC application view I cannot call or even see the #Html.EditorFor method. The intellisense never pops it up.
Any ideas?
EDITED: Same goes with #Html.BeginForm. The method never pops up!
It sounds like the namespace is not available.
In the first instance, try adding
#using System.Web.Mvc.Html
at the top of your view to see if that helps. If it does, then there is probably a problem with your View specific Web.config. In the root of your Views folder there should be a Web.config file. Note that if you use Areas then there should be one of those in each Views folder.
Inside that Web.config there should be a section like the following:
<configuration>
...other stuff...
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.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.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="WebApplication1" />
</namespaces>
</pages>
</system.web.webPages.razor>
...other stuff...
</configuration>
Essentially that section is the equivalent of adding using statements inside each view.
After updating my build via an SVN repo, all of a sudden all my view code is broken because my Views can't seem to resolve the System.Web.Mvc namespace. I keep getting the above message with reference to Html methods (e.g. Html.DisplayFor, Html.RadioButton, etc.in Mvc views. However, the namespace is clearly included in the Web.config
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.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" />
</namespaces>
</pages>
</system.web.webPages.razor>
Any other ideas as to why this might not work?
Just a shot in the dark, but I would check the reference path for System.Web.Mvc. Perhaps you are referencing some version of the System.Web.Mvc library that no longer exists in the directory location on your machine since u pulled down a fresh copy of the repo.
Hi can someone tell me how to use Kendo UI with asp.net web application?
Because when I try to create an asp.net application and added kendo.mvc.dll in my bin folder.
Now I've added
<%= Html.Kendo().Calendar().Name("calendar") %>
in my default.aspx page. Now it is saying "The name HTML does not exist in the current context"
Can someone help me what is the issue in that?
Thanks in advance
You are trying to use Kendo for MVC when your web application is not MVC.
You need to use Kendo UI WEB
http://www.kendoui.com/download.aspx
Why don't you follow these simple steps from the documentation?
http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/introduction#manually-add-kendo-ui-to-aspnet-mvc-applications
In particular I'm referring to the step 7 where you must add the namespece in your web.config:
<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.Linq" />
<add namespace="System.Collections.Generic" />
<add namespace="Kendo.Mvc.UI" />
</namespaces>
I am developing a Web app that is based on ASP.NET 3.5, and i added some page from ASP.NET MVC, everything is ok, until i use the "HTML" helper class, then the page is not being able be render, because this is not recognized.
For Example : Html.BeginForm() => this is not recognize as a method
But if i used "System.Web.Mvc.Html.FormExtensions.BeginForm", which is a extension method itself, it work fine.
Environment : ASP.NET MVC 2 and ASP.NET 3.5
Anyone experiencing this problem?
Thanks.
Do you have the System.Web.Mvc.Html namespace included in web.config's page assemblies list? I.e.:
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
**<add namespace="System.Web.Mvc.Html" />**
<add namespace="System.Web.Routing" />
</namespaces>
</pages>