c# - UrlHelper.Action doesn't map to the area that the controller is in correctly -
Update 2
OK - It seems that my question Changing then a little bit: -)
I have now come to know that URLLar.Action does not appear to solve the URL correctly in any field unless the name of the area is clearly Not specified from. If this is not specified then it seems that whatever area we are currently changing, it seems that it is working from one part of the site, but then the same link in the second area Resolves.
> Either I have made some fun to do this or I do not understand how this verb method works.UPDATE 1
I can do the following:
Return Assistant. Action ("Add", "Product", New {domain = "Store Management"});
Which changes my question a bit.
How does MVCU routing do not isolate controllers with the same name and resolves one with the specified methodology?
Original post
Hey everyone,
I have created a helpful method on the URL helper class and there is a small problem With one of the routes.
The code here is helpful for the question in question:
public static string AddProduct {This UrlHelper Assistant} {return helper.Action ("add", "product") ; }
I basically have two controllers called "Products" which are in different areas of the site. One is used for browsing the products in one of these and for managing other products. for. Only one of the product controllers has an "action" action method.
When I exclude the value of AddProduct
& lt;%: Url.AddProduct ()% & gt;
The name of this area is resolved to the existing area which I am browsing and not the right area for the product controller with the action method.
Is there something needed to be established in the streets? I do not know exactly how routing works with the URL halper. Action so I do not know if I am trying to do this.
Cheers for any help.
This is the default behavior of ASP .NET routing.
When the verb (and see) in the "Area" is considered to be executed by the controller and verb name in the default places, the verb is not executed unless otherwise specified in the verb. The default location is: {controller} = controller name, {area} = name of the field
Controller:
"area / {region} / {controller} /" controller / {controller} "
view: "areas / {area} / visual / {controller} /" "area / {field} / view / share /" view / share " Code> If you can not give an area in the area of Don Marg, which will never search beyond these places. The area is similar to the place where you are calling your assistant. If you are in the root level (not in any area), then it will be limited to
"controller / {controller}" // controller "view / {controller} /" // views. The problem / number of shares / views /
The problem was that when you searched for a region where "area / region1 / {controller} /"
And you searched in Zone 2 "area / region2 / {controller} /"
(and both of controller / product
and controllers / shared
was searched). Where you find it in the right area, because it used to fix the default search location, but was not in another area because the controller was in only one physical area.
You did add area, it asks to search in a predefined area, so it will go straight to "areas / store management / view / product /"
and action Search for a scene defined in action.
There is little to keep a blank helper method returning a URL. Method, but maybe it was just for performance.
(I see that the question is very old but I think it can be for future reference too)
Comments
Post a Comment