Question

I've got MVC3Contrib installed.. strange thing is, the examples show that I could use them to render links in razor pages, something like this:

@( Html.ActionLink<HomeController>(c => c.Index(), "Go home") )

This somehow never works for me.. Although, in my controllers, I can do

return new RedirectToRoute<MyController>(c => c.Index()); 

just fine.. The error I get is The non generic link ActionLink cannot be used with type arguments

It is as if the contrib isn't installed.. Infact, I don't even see the mvc future action link option in the intellisense

enter image description here

I just can't figure out why it is behaving so, Do I need to do anything extra here?

If you need any other info, please ask, I don't know what else I should be giving out here..


EDIT
Oh btw, I'm using MVC Areas, if that matters, I have about 3 areas and then the main controllers etc..

Était-ce utile?

La solution

Make sure that the Microsoft.Web.Mvc namespace is in scope which is where thos extension methods are defined:

enter image description here

or add it to the <namespaces> section of your ~/Views/web.config file in order to bring this namespace in all views:

<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="Microsoft.Web.Mvc" />
    </namespaces>
  </pages>
</system.web.webPages.razor>

I suppose that in your controller code you have added using MvcContrib.ActionResults; which is why you are able to see the RedirectToRouteResult<T> class available.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top