I have a shared master page which I am using from 2 different areas in my mvc 2 app. The master page has an action link which currently specifies the controller and action, but of course the link doesn't work if I'm in the wrong area. I see no overload for actionlink that takes an area parameter, is it possible to do?
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- parameters in routing do not work MVC 3
- There is no ViewData item with the key 'taskTy
- TextBoxFor decimal
- Install ASP.NET 5.0 version of System.ServiceModel
相关文章
- “Dynamic operations can only be performed in homog
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
- How to get server path of physical path ?
- Cannot implicitly convert Web.Http.Results.JsonRes
Use:
Note:4th parameter is to pass route
Values
, if you pass an empty parameter it will consider root structure and if you pass appropriate value it use it as area.Also do not forget to use
null
ornew{}
as the 5th parameter because passingnull
ornew {}
while creating action link will not overload method for(text,action,controller,route data)
or its(text,action,controller,route data,html attribute)
so use the proper methodSomething I ran into right after this, that I imagine others might run into: If you need to link from within an area to an action not in an area, you still need to specify the Area as empty string.
For instance, I moved some MVC code into an area, and found I needed to update urls in the master page that referenced other pages on the site.
To specify an url to something not in an area, use
A neat trick you can do if you are using an area a lot in a View is define it as a variable at the top:
Figured it out..
If you can not use standart web aplication link like About, Home, Contac etc from area. You change lines
from
Views\Shared_Layout.cshtml
In MVC2 giving
area="root"
worked for me as below