breadcrumbs - How to Change Controller and Action Display Names in Asp.net MVC -
I'm using the controller and action name to show up in my view-breadcrumbs
@viewcontext. Root data Price ["Controller"] / @ViewContax RootData. Value ["Action"]
The output of this query
HRmPerson certificate / create
but for the controllers I want to show different names. IE: Certification / New Certificate
Can I change the names and names of the controllers?
Edit
Actually, I had trouble with some solution for you that you said but that is, i.e. In my person model, now it has two more variables, route 1 and route 2. Route 1 = "person information", root 2 = "action name: see the person". But I'm using the same view while editing or using this model. I'm in trouble.
You should not use the internal names of controllers and actions on the website. This will make things difficult to maintain and optimize the visual side of things (as you can see with this question) and mix your server side's meta-data inappropriately with the presentation level Are there.
A better approach is to create a basemodel
object, which is always intended to show in your path:
public class bismell {public String root 1 {get; Set;} public string root 2 {get; Set;}}
Setup can change clearly - you can store different names or even the list & lt; String & gt;
, but the idea is not to get the controller and action names in your view harder.
Then use this passage pass through each view and use your route Use these values to display
@model BaseModel ... @model.rout1 / @model.orout2
Every single model that you have in each single view on your site Those who use this layout should be from BaseModel
. Thus these properties will be available for use on every single view. So if your current page is called MyModel
on a given page, then change its definition to public class MyModel: BaseModel
and you BaseModel
You can use. Code> properties too.
Comments
Post a Comment